//文件中写字
public class FilePrintWriter {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String path = "E:/Dev/Works/JavaUtils/file";
try {
File f1 = new File(path + "/3.txt");
if (!f1.exists()) {
f1.createNewFile(); // 创建
}
PrintWriter pw = new PrintWriter(new FileWriter(f1));
pw.print("123");
pw.close();
FileOutputStream outputStream = new FileOutputStream(f1);
outputStream.write("\ntest".getBytes());
outputStream.close();
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
}