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

📄 read.java

📁 一个基于Java语言开发的计算器的源代码
💻 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 + -