Java 文件读写
import java.io.*;
import java.math.*;
public class Main{
public static void main(String[] args) throws Exception{
//读取文件
BufferedReader br =new BufferedReader(new FileReader("E:1.txt"));
String line = "";
while((line = br.readLine()) != null){
System.out.println(line);
int g=Integer.parseInt(line);//字符串转数字
}
br.close();
int g=Integer.parseInt(line);
//写文件
BufferedWriter brout = new BufferedWriter(new FileWriter("E:2.txt"));
brout.write("输出的内容");
brout.flush(); //刷新缓冲区的数据到文件
brout.close();
}
}