Results 1 to 3 of 3
Thread: Open file for reading.
- 03-03-2011, 07:42 AM #1
Member
- Join Date
- Mar 2011
- Posts
- 2
- Rep Power
- 0
Open file for reading.
What is the simplest method, i.e. The bare minimum to open a file, read it to a string and then close the file?
Also, what is the best way to store the strings that are coming in? For example I read from another site that you can just add new lines to the StringBuilder class. For example, would ArrayList<String> be the best way to do that?
Finally, if I am to read a series of characters rather than the string, how can I process all that while I have the file open... ie hasNext() something?
So, what is the easiest method?
- 03-03-2011, 07:55 AM #2
Senior Member
- Join Date
- Jan 2011
- Location
- Bangalore, India
- Posts
- 102
- Rep Power
- 0
You are right. StringBuilder is a good option.
ArrayList is better option if your requirement is to add lines. I said better because if in your requirement you need to get the 2nd line, then it's not so easy with StringBuilder. But it ArrayList you can easily do it using indexes.
- 03-04-2011, 05:50 AM #3
Member
- Join Date
- Mar 2011
- Posts
- 2
- Rep Power
- 0
Similar Threads
-
can't open a .jar file
By demichelis89 in forum Java AppletsReplies: 46Last Post: 10-25-2010, 11:45 AM -
How to show or open a file download or file save dialog box
By java_bond in forum New To JavaReplies: 0Last Post: 03-05-2010, 04:21 AM -
Different Files Open in File -> Open Workspace
By mgm2010 in forum JCreatorReplies: 0Last Post: 04-11-2009, 02:14 PM -
Open File
By JavaLerner in forum SWT / JFaceReplies: 5Last Post: 07-12-2008, 06:41 PM -
To open an image file such as Jpeg file using JAva Program
By itmani2020 in forum Advanced JavaReplies: 10Last Post: 07-11-2008, 09:57 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks