📄 randomlong.java
字号:
package util;import java.io.*;public class RandomLong { static String randomFile = "random"; static String positionFile = "position"; static int pos; /** * @param args */ public static void main(String[] args) { LineNumberReader posIn; PrintWriter posOut; BufferedInputStream bytes; String line; int b; long l; // TODO Auto-generated method stub try{ posIn = new LineNumberReader(new FileReader(positionFile)); line = posIn.readLine(); pos = Integer.parseInt(line); posIn.close(); // overread the first pos bytes bytes = new BufferedInputStream(new FileInputStream(randomFile)); for(int i=0; i<pos; i++){ bytes.read(); } l = 0; for(int i=0; i<8; i++){ l = l << 8; b = bytes.read(); if(b==-1){ throw new IllegalStateException("EOF reached."); } l = l | b; } pos += 8; posOut = new PrintWriter(new FileWriter(positionFile),true); posOut.println(pos); System.out.println("N盲chster Long: "+l); }catch(Exception e){ System.err.println(e); e.printStackTrace(); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -