want to read a nested ArrayList from a text file.
I have a nested java ArrayList in a text file. I need to read that ArrayList in a Java program, and work with it. The problem is, whenever I am reading the file, I could only read the ArrayList as a String. Can anyone please help me to read the List in the file, as the same list in the java program?
Actually, I have created a java Arraylist in another program, and have copied the arraylist to a text file. The Arraylist is nested: (e.g. [a, b, [c, [d, e]]] ) Now, I need to read that ArrayList from the text in a java program and work with it. The problem I am facing is, I can read the ArrayList only as a string from the file. I am using :
" FileReader fr = new FileReader ("javaList.txt");
BufferedReader br = new BufferedReader (fr);"
Now, converting that string to a similar nested Arraylist is proving to be difficult for me. I don't know how to do it.
Thanks a lot!
Was the arraylist written to file as a serialized object or just plain text? If plain text, then what structure was it written? Just reverse the method you used for writing to read it back in.
Hi, i read a python List and converted it to a Java list in Jython. This is the code in Jython :
p = listquote.LineParser() // read the python list from the file as a list.
aList = p.feed(fileList)
output = open('javaList.txt','w')
print >> output, anotherJavaList
Now, I need to read that List from javaList.txt into a Java program, and work with that.
You may just have to save the list in a format you can easily parse so it can be recreated. You may want to consider saving the file in XML format.
Just as an example:
By sarasahg in forum Java
Last Post: 12-13-2005, 03:36 AM
By crazyguitarchik in forum Java
Last Post: 11-30-2005, 08:12 PM
By Ted Young in forum VB Classic
Last Post: 08-21-2000, 09:47 PM
By Gabriele in forum Java
Last Post: 05-03-2000, 03:38 AM
By deborah in forum authorevents.kurata
Last Post: 04-17-2000, 01:33 PM
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL