日期:2014-05-20 浏览次数:20844 次
public static void main(String[] args) { File file = new File("E:\\Temp\\hello.txt"); try { if (!file.exists()) { file.createNewFile(); } PrintWriter writer = new PrintWriter(file); writer.print("Hello, how are you"); writer.flush(); } catch (IOException e) { e.printStackTrace(); } }
------解决方案--------------------
java.io.FileInputStream;
java.io.FileOutputStream;
java.io.BufferedOutputStream;
java.io.BufferedReader;
java.io.InputStreamReader;
java.io.FileNotFoundException;
java.io.IOException;
java.io.File;
看一下这些API,对你的问题会有帮助的.