import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
public class iofiles {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) {
FileOutputStream fos=null;
try {
File dir = new File("E:\\tempfile");
if (!dir.exists()) {
dir.mkdir();
}
fos = new FileOutputStream("E:\\tempfile\\2.txt",true);
String str = "guiling";
/* byte[] buf = str.getBytes();
fos.write(buf);*/
fos.write(str.getBytes());
fos.close();
} catch (Exception e) {
System.out.println(e.toString()+"--");
}
finally{
if(fos!=null){
try {
fos.close();
} catch (IOException e) {
throw new RuntimeException(""+e);
}
}
}
}
}
文件输入的例子。
最新推荐文章于 2022-11-08 16:30:23 发布