Zapisywanie danych samochodu do pliku
Dane wyjściowe:
12.02.2012
2000
Opel
2003
Kompilator: Eclipse
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import javax.swing.JOptionPane;
public class glowna {
//Zapisywanie danych samochodu do pliku.
public static void main(String[] args) throws IOException {
FileWriter plik = new FileWriter("output.txt");
BufferedWriter bufer = new BufferedWriter(plik);
String data=JOptionPane.showInputDialog("Podaj datę: ");
String cena=JOptionPane.showInputDialog("Podaj cenę: ");
String marka=JOptionPane.showInputDialog("Podaj markę: ");
String rok=JOptionPane.showInputDialog("Podaj rok: ");
bufer.write(data);
bufer.newLine();
bufer.write(cena);
bufer.newLine();
bufer.write(marka);
bufer.newLine();
bufer.write(rok);
bufer.newLine();
bufer.close();
}
}