import java.io.*;
public class FileOutputTest {
public static void main(String[] args) {
String string = "Hello Java";
try {
String path = "/Users/zaferteker/Private/Books/Documents/TestFileOut.txt ";
FileOutputStream fos = new FileOutputStream(path);
// Tüm string char char dosyaya yazılıyor.
for (int i = 0; i < string.length(); i++) {
char c = string.charAt(i);
fos.write(c);
}
fos.close();
System.out.println("string dosyaya yazıldı");
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Dosyayı İndir