Java Buat file txt
File myObj = new File("path");
myObj.createNewFile();
FileWriter myWriter = new FileWriter("path");
myWriter.write("text");
myWriter.close();
Vails
File myObj = new File("path");
myObj.createNewFile();
FileWriter myWriter = new FileWriter("path");
myWriter.write("text");
myWriter.close();
String fileData = "yourContent";
FileOutputStream fos = new FileOutputStream("yourFile.txt");
fos.write(fileData.getBytes());
fos.flush();
fos.close();
@Test
public void givenUsingJava7_whenWritingToFile_thenCorrect()
throws IOException {
String str = "Hello";
Path path = Paths.get(fileName);
byte[] strToBytes = str.getBytes();
Files.write(path, strToBytes);
String read = Files.readAllLines(path).get(0);
assertEquals(str, read);
}
System.out.println("eimai o kalyteros programmer!!!");
system.out.println("Hello Chaim");
System.out.println("oxi egw eimai!!!");