Follow along with the video below to see how to install our site as a web app on your home screen.
Anmerkung: This feature currently requires accessing the site using the built-in Safari browser.
import java.io.*;
public class Write {
public static void main(String[] args) throws IOException {
File outputFile = new File("outagain.txt");
FileWriter out = new FileWriter(outputFile);
String[] data = String[3]
data[0] = "eins; zwei; drei;";
data[1] = "eins; zwei; drei;";
data[2] = "eins; zwei; drei;";
for(int i = 0; i < data.length; i++) {
out.writeln(data[i]);
}
out.close();
}
}
sintakx hat gesagt.:dann hab ich gleich noch eine frage
wenn ich das in eine for schleife verpacke, dann schreibts die datei jeedesmal neu und löscht das was vorher drin war. wie kann ich es machen dass er einfach eine zeile dazu fügt, anstatt das file zu überschreiben?
nochmals danke im voraus
FileWriter
public FileWriter(String fileName,
boolean append)
throws IOException
Constructs a FileWriter object given a file name with a boolean indicating whether or not to append the data written.
Parameters:
fileName - String The system-dependent filename.
append - boolean if true, then data will be written to the end of the file rather than the beginning.
Throws:
IOException - if the named file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason
public static void main(String[] args) throws IOException {
File outputFile = new File("outagain.txt",true);