public class Fileoutputstream {
/** Creates a new instance of FileOutputStream */
public Fileoutputstream() {
}
public static void main(String[] args) {
try {
String str ="好好学习Java";
byte[] words = str.getBytes();
OutputStream fos=new FileOutputStream("1.txt");
fos.write(words, 0, words.length);
System.out.println("Text文件已更新!");
fos.close();
} catch (IOException obj) {
System.out.println("创建文件时出错!");
}
} }
程序中的OutputStream fos=new FileOutputStream("1.txt");为什么错误呢?
/** Creates a new instance of FileOutputStream */
public Fileoutputstream() {
}
public static void main(String[] args) {
try {
String str ="好好学习Java";
byte[] words = str.getBytes();
OutputStream fos=new FileOutputStream("1.txt");
fos.write(words, 0, words.length);
System.out.println("Text文件已更新!");
fos.close();
} catch (IOException obj) {
System.out.println("创建文件时出错!");
}
} }
程序中的OutputStream fos=new FileOutputStream("1.txt");为什么错误呢?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货