日期:2014-05-20 浏览次数:20971 次
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
public class Test{
public static void main(String args[]) throws Exception{//异常抛出,不处理
File f = new File("d:"+File.separator+"test.txt");
OutputStream out = null; //准备好一个输出流对象
out = new FileOutputStream(f); //通过对象多态性,进行实例化
String str="hello world";
byte b[]=str.getBytes();
out.write(b);
out.close();
}
}
import java.io.File;
import java.io.FileOutputStream;
public class Test{
public static void main(String args[]) throws Exception{
File f = new File("d:"+File.separator+"test.txt");
FileOutputStream out = new FileOutputStream(f);
String str="hello world";
byte b[]=str.getBytes();
out.write(b);
out.close();
}
}