package com.derun.inputstream;
import java.io.FileOutputStream;
import java.io.IOException;
public class WriteFileDome {
public static void main(String[] args) {
try {
System.out.println("输出要保存文件的内容");
int count, n = 512;
byte[] buffer = new byte[n];
count = System.in.read(buffer);
FileOutputStream os = new FileOutputStream("WriteFile.txt");
os.write(buffer, 0, count);
os.close();
System.out.println("已保存到WriteFile.txt中");
} catch (IOException ioe) {
System.out.println(ioe);
} catch (Exception ie) {
System.out.println(ie);
}
}
}
import java.io.FileOutputStream;
import java.io.IOException;
public class WriteFileDome {
public static void main(String[] args) {
try {
System.out.println("输出要保存文件的内容");
int count, n = 512;
byte[] buffer = new byte[n];
count = System.in.read(buffer);
FileOutputStream os = new FileOutputStream("WriteFile.txt");
os.write(buffer, 0, count);
os.close();
System.out.println("已保存到WriteFile.txt中");
} catch (IOException ioe) {
System.out.println(ioe);
} catch (Exception ie) {
System.out.println(ie);
}
}
}