ioStream.java
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class iostream_sample {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
File f = new File("hello.test");
if(!f.exists() ){
f.createNewFile();
System.out.println("creat file success!");
}
FileOutputStream outStream = new FileOutputStream(f);
outStream.write("hello world".getBytes());
outStream.close();
FileInputStream inStream = new FileInputStream(f);
byte [] buf = new byte[1024];
int len = inStream.read(buf);
System.out.println(new String(buf, 0, len));
}
}