Ex_FileOutStream
import java.io.*;
public class Ex_FileOutStream{
public static void main(String args[]){
String s = "Java output";
byte[] data = s.getBytes();
System.out.println("Write s to file");
System.out.println("Data length"+data.length+" byte");
FileOutputStream fos = null;
try{
fos = new FileOutputStream("SampleFile2.txt",true);
fos.write(data);
}catch(IOException e){
}finally{
try{
fos.close();
}catch(IOException e){}
}
}
}
Write s to file
Data length11 byte
沒有留言:
張貼留言