Ressourcen:
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
public class WriteFileExample {
public static void main(String[] args) {
FileOutputStream fop = null;
Datei;
Content String = "Der hinzugefügte Inhalt";
try {
file = new File("test.txt");
fop = new FileOutputStream(Datei);
// Erstelle die Datei, wenn sie nicht existiert
if (!file.exists()) {
file.createNewFile();
}
// in Binärdaten umwandeln
byte[] contentEnBytes = content.getBytes();
fop.write(EnBytes content);
fop.flush();
fop.close();
System.out.println("Bearbeitung abgeschlossen!");
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (fop != null) {
fop.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
Please disable your ad blocker and refresh the window to use this website.