import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class FileTest {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
File fileTest = new File("Fred.txt");
if (fileTest.exists()) {
fileTest.delete();
} else {
byte[] b = "Freddie".getBytes();
byte[] z = new byte[1024];
fileTest.createNewFile();
System.out.println("ok");
System.out.println(fileTest.getAbsolutePath());
FileOutputStream in = new FileOutputStream("Fred.txt");
FileInputStream out = new FileInputStream("Fred.txt");
in.write(b);
int len = out.read(z);
System.out.println(new String(z, 0, len));
}
}
}