?? read.java
字號:
package process;import java.io.*;import java.util.*;public class Read { private String sourcefile; private FileInputStream fis=null; private static DataInputStream dis=null; public Read(String sourcefile){ this.sourcefile=sourcefile; try{ fis=new FileInputStream(sourcefile); dis=new DataInputStream(fis); }catch(Exception e){ System.out.println("鏁版嵁婧愭枃浠舵病鎵懼埌"); } } public String getLoginName(){ try{ byte[] bs=readByte(32); String s=new String(bs); return s.trim(); }catch(Exception e){ throw new RuntimeException(); } } public int getPid()throws Exception{ readByte(4);//璺寵繃鏃犵敤瀛楄妭 readByte(32); int i=dis.readInt(); return i; } public short getType()throws Exception{ return dis.readShort(); } public long getTime()throws Exception{ readByte(6);//璺寵繃鏃犵敤瀛楄妭 int time1=dis.readInt(); int time2=dis.readInt(); return time1*1000L+time2; } public String getIP()throws Exception{ readByte(4); readByte(20); readByte(2);//璺寵繃鏃犵敤瀛楄妭 byte[] bs=readByte(257); return (new String(bs)).trim(); } public void endOnceRead()throws Exception{ readByte(1); } public boolean isEnd()throws Exception{ return dis.available()==0; } public static byte[] readByte(int size)throws Exception{ byte[] bs=new byte[size]; for(int i=0;i<size;i++){ bs[i]=dis.readByte(); } return bs; } public static void main(String[]args)throws Exception{ Read read=new Read("wtmpx"); while(!read.isEnd()){ System.out.println(read.getLoginName()+":"+read.getPid()+":"+read.getType()+":"+read.getTime()+":"+read.getIP()); read.endOnceRead(); } }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -