62,620
社区成员
发帖
与我相关
我的任务
分享
String fileName = "d:/test.txt";
try {
DataOutputStream out = new DataOutputStream(
new BufferedOutputStream(new FileOutputStream(fileName,true)));
for (int i = 0 * 1024 * 1024; i < 1 * 1024 * 1024; i++) {
out.writeInt(i);
}
out.close();
DataInputStream input = new DataInputStream(new BufferedInputStream(new
FileInputStream(fileName)));
int i = 0;
while(i < 10 * 1024){
System.out.println(input.readInt());
i++;
}
input.close();
} catch (Exception e) {
e.printStackTrace();
}
try{
FileOutputStream out = new FileOutputStream("D:/test.dat");
PrintStream p = new PrintStream(out);
for(int i = 0;i < 1000000;i++){
p.println(i);
}
p.close();
}catch(FileNotFoundException e){
e.printStackTrace();
}