📄 numsio.java
字号:
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Random;
/*
* Created on 2006-11-13
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
/**
* @author Shenjun
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class NumsIO {
/**
*
*/
public NumsIO(String out,int N) {
try {
output=new FileOutputStream(out);
int i=0;
int tempRandom;
while(i<N){
tempRandom=r.nextInt(10);
System.out.print(" "+tempRandom);
try {
output.write(tempRandom);
i++;
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
output.close();
// TODO Auto-generated constructor stub
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/**
*
*/
private void GetNums(String in) {
try {
FileInputStream input=new FileInputStream(in);
try {
System.out.println("Get the NUMS!!");
int t=input.read();
while (t!=-1) {
//addToHead(t);
System.out.print(" "+t);
t=input.read();
}
input.close();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private FileOutputStream output;
private Random r=new Random();
private int N=5000;
public static void main(String[] args) {
NumsIO numProducer=new NumsIO("num1.txt",1000);
NumsIO numProducer2=new NumsIO("num2.txt",1000);
//numProducer.GetNums("num2.txt");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -