5
Is there any mechanism to store the data of a file in a Linkedlist .txt
? For example, how would this list have as elements the strings "Caio", "Pedro" and "Luiza"?
import java.io.*;
public class teste {
public static void main ( String args [] ) throws IOException {
LinkedList<String> linkedlist = new LinkedList<String>(); /*lista de Strings*/
File arquivo = new File("C:\\NetBeans\\teste.txt");
arquivo.createNewFile();
FileWriter fw = new FileWriter(arquivo, true);
BufferedWriter bw = new BufferedWriter(fw);
bw.write("Caio Pedro Luiza");
bw.close();
fw.close();
}
}
What is your real question? read the file . txt and then store in Linked?
– Wellington Avelino
Yeah, that’s right, that’s right
– poirot
Have you ever done it? It’s easier to guide you
– Wellington Avelino
Okay, I’ve edited my question
– poirot
These names are separated by Comma, space or are in different lines?
– Wellington Avelino
Are separated by space
– poirot
I removed the [linkedlist] tag, because in my opinion your problem isn’t about processing linked lists, you’re just putting the strings inside a list (which didn’t even need to be a linked list).
– Victor Stafusa
I recommend reading this page here: https://docs.oracle.com/javase/7/docs/api/java/io/FileInputStream.html
– cicada 3301