?? account.java
字號:
/*
* Created on 2004-7-8
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package com.north.phonebook.model;
import java.io.*;
/**
* @author P2800
*
* TODO To change the template for this generated type comment go to Window -
* Preferences - Java - Code Style - Code Templates
*/
public class Account
{
private String userName = "";
private String mobilePhone = "";
private String email = "";
private String phone = "";
public Account(String userName,String mobilePhone,String email,
String phone)
{
this.userName = userName;
this.mobilePhone = mobilePhone;
this.email = email;
this.phone = phone;
}
private Account()
{
}
/**
* @return Returns the email.
*/
public String getEmail()
{
return email;
}
/**
* @param email The email to set.
*/
public void setEmail(String email)
{
this.email = email;
}
/**
* @return Returns the mobilePhone.
*/
public String getMobilePhone()
{
return mobilePhone;
}
/**
* @param mobilePhone The mobilePhone to set.
*/
public void setMobilePhone(String mobilePhone)
{
this.mobilePhone = mobilePhone;
}
/**
* @return Returns the phone.
*/
public String getPhone()
{
return phone;
}
/**
* @param phone The phone to set.
*/
public void setPhone(String phone)
{
this.phone = phone;
}
/**
* @return Returns the userName.
*/
public String getUserName()
{
return userName;
}
/**
* @param userName The userName to set.
*/
public void setUserName(String userName)
{
this.userName = userName;
}
public byte[] serialize() throws IOException
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
dos.writeUTF(userName);
dos.writeUTF(mobilePhone);
dos.writeUTF(email);
dos.writeUTF(phone);
baos.close();
dos.close();
return baos.toByteArray();
}
public static Account deserialize(byte[]data)throws IOException
{
ByteArrayInputStream bais = new ByteArrayInputStream(data);
DataInputStream dis = new DataInputStream(bais);
Account account = new Account();
account.userName = dis.readUTF();
account.mobilePhone = dis.readUTF();
account.email = dis.readUTF();
account.phone = dis.readUTF();
bais.close();
dis.close();
return account;
}
public static boolean matches(byte[] data,String userName) throws IOException
{
ByteArrayInputStream bais = new ByteArrayInputStream(data);
DataInputStream dis = new DataInputStream(bais);
try
{
return (dis.readUTF()).equals(userName);
}
catch(IOException e)
{
e.printStackTrace();
return false;
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -