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

📄 account.java

📁 RMS记录集源码
💻 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 + -