文件的读写操作

public class ReadAndWrite {
	public static void main(String[] args) {
		try {
                        //文件读入
			InputStream in=new FileInputStream(new File("./88.txt"));
			BufferedReader br=new BufferedReader(new InputStreamReader(in,"GBK"));
			
                        //文件写入
			OutputStream out=new FileOutputStream("./**.txt");
			BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(out));
			
			String line=null;
			
			while((line=br.readLine())!=null){
				bw.write(line);
			}
			bw.close();
			out.close();
			in.close();
			br.close();
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

 

你可能感兴趣的:(read and write)