⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 user.java

📁 java 完全探索的随书源码
💻 JAVA
字号:
import java.io.*;public class User implements Serializable{  // Private instance variables  private String userName = null;  private String password = null;  // Constructor  public User( String name, String passwd )  {    super();    userName = name;    password = passwd;  }  //Public accessors  public String getUserName()  {    return userName;  }  public void setUserName( String name )  {    userName = name;  }  public String getPassword()  {    return password;  }  public void setPassword( String passwd )  {    password = passwd;  }  // Implement the neccessary writeObject method for handling the  // serialization of this object other than the default way  private void writeObject( ObjectOutputStream out ) throws IOException  {    String userNameEncrypted = encryptStr( getUserName() );    String passwordEncrypted = encryptStr( getPassword() );    out.writeObject( userNameEncrypted );    out.writeObject( passwordEncrypted );  }  // Implement the neccessary readObject method for handling the  // serialization of this object other than the default way  private void readObject( ObjectInputStream in )    throws IOException, ClassNotFoundException  {    String userNameEncrypted = (String)in.readObject();    String passwordEncrypted = (String)in.readObject();    setUserName( decryptStr( userNameEncrypted ));    setPassword( decryptStr( passwordEncrypted ));  }  // Extremely simple encryption routine just do show the point  // of something being done with the data  public String encryptStr( String normalStr )  {    StringBuffer buf = new StringBuffer( normalStr );    buf.reverse();    return buf.toString();  }  // Simple decryption routine  public String decryptStr( String encryptStr )  {    StringBuffer buf = new StringBuffer( encryptStr );    buf.reverse();    return buf.toString();  }  // Override the toString() method from Object to pretty print a User object  public String toString()  {    StringBuffer strBuf = new StringBuffer( "User: " );    strBuf.append( getUserName() );    strBuf.append( " Password: " );    strBuf.append( getPassword() );    return strBuf.toString();  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -