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

📄 cabecera.java

📁 multiplataform real time Linux monitor
💻 JAVA
字号:
/** LiMon-JClient *  Copyright (C) 2006 Marcelo Busico * *  Author:  Marcelo Busico    marcelobusico@gmail.com * *  This program is free software which I release under the GNU General Public *  License. You may redistribute and/or modify this program under the terms *  of that license as published by the Free Software Foundation; either *  version 2 of the License, or (at your option) any later version. * *  This program is distributed in the hope that it will be useful, *  but WITHOUT ANY WARRANTY; without even the implied warranty of *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *  GNU General Public License for more details.  Version 2 is in the *  LICENSE.txt file in the top level directory of this distribution. *  *  To get a copy of the GNU General Puplic License, write to the Free Software *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */package limonclient;import java.io.*;public class Cabecera {    private int identificador;    private String password;        public final static int IdConfirmaPassword=1;    public final static int IdPedirEstadoMicro=10;    public final static int IdPedirEstadoMemoria=11;    public final static int IdPedirEstadoIntercambio=12;    public final static int IdPedirUpTime=13;    public final static int IdPedirTemperatura=14;    public final static int IdPedirEstadoServidores=15;    public final static int IdPedirEstadoDisco=16;    public final static int IdPedirHora=17;    public final static int IdPedirFecha=18;        public final static int IdDevolverEstadoMicro=110;    public final static int IdDevolverEstadoMemoria=111;    public final static int IdDevolverEstadoIntercambio=112;    public final static int IdDevolverUpTime=113;    public final static int IdDevolverTemperatura=114;    public final static int IdDevolverEstadoServidores=115;    public final static int IdDevolverEstadoDisco=116;    public final static int IdDevolverHora=117;    public final static int IdDevolverFecha=118;        public final static int IdPasswordCorrecta=200;    public final static int IdPasswordIncorrecta=201;    public final static int IdDesconexion=202;                /** Crea una nueva instancia de Cabecera */    public Cabecera() {        identificador=0;        password="";    }    public Cabecera(int id, String pass) {        identificador=id;        password=pass;    }        // Establece el identificador de cabecera    public void setIdentificador(int id)    {        identificador=id;    }        //Devuelve el identificador de cabecera    public int getIdentificador()    {        return identificador;    }        // Establece la contraseña de la conexión    public void setPassword(String pass)    {        password=pass;    }        //Devuelve la contraseña de cabecera    public String getPassword()    {        return password;    }    public void recibirCabecera(java.io.DataInputStream in) throws IOException    {        //Lee el identificador de cabecera        identificador = in.readInt();        // Array de bytes auxiliar para la lectura de la cadena.        byte [] aux = null;        aux = new byte[64];  // Se le da el tamaño         int i;                //Lee la password        in.read(aux, 0, 64); // Se leen los bytes                //Se busca el final de la cadena        for(i=0;i<64;i++)        {            if(aux[i]==0)                break;        }                //Copia solo los bytes no nulos en pass        byte [] pass = new byte[i];        for(int j=0; j<i; j++)            pass[j]=aux[j];                password = new String (pass); // Se convierten a String    }    public void enviarCabecera(java.io.DataOutputStream out) throws IOException    {        //Escribe el identificador de la cabecera        out.writeInt(identificador);                //Envia la password como bytes        out.writeBytes(password);        //Se envía el \0 del final y        //envia el relleno de la password hasta 63 bytes        out.writeByte ('\0');                for(int i=password.length()+1;i<64;i++)            out.writeByte(0);    }}

⌨️ 快捷键说明

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