Witajcie :)
W jaki sposób zapisać dane z LinkedList do pliku??
public class Address {
private String name;
private String city;
Address(String n, String c)
{
name = n;
city = c;
}
public String toString()
{
return name + "\n" + city + "\n";
}
}
import java.io.*;
import java.util.*;
public class Linq {
public static void main(String[] args) throws IOException {
LinkedList<Address> pb = new LinkedList<>();
pb.add(new Address("Jan Kowalski", "Warszawa"));
DataOutputStream out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream("C:/Data.txt")));
out.writeUTF("");
out.close();
DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream("C:/Data.txt")));
System.out.println(in.readUTF());
in.close();
}
}