Results 1 to 6 of 6
- 11-17-2008, 04:11 AM #1
Member
- Join Date
- Nov 2008
- Posts
- 67
- Rep Power
- 0
[SOLVED] How do I read from a text file
I'm asking this question because I want to learn how to read and write from a text file.
Let's say I have a text file names.txt that has 1000 names listed 1 name in each row. It is saved in "C:/names.txt".
I have 3 scenarios:
1. I want to set each name into an array.
String[] theNames = new String[1000]
2. I want to take each name and add "Mr. " before it. Save the new names to the same text file.
3. Same as #2, except create a new text file (theNewNames.txt) and save the names there.
~~~~~~~~~~~~~~
How would I do each of these?
-
Have you read the sun IO tutorial? That's where I'd start.
Oh and 2 and 3 would be the same, I think, only for 2. I'd rename the new file to the old file when done. That way you can rename things on the fly .
- 11-17-2008, 04:23 AM #3
Member
- Join Date
- Nov 2008
- Posts
- 67
- Rep Power
- 0
Where would I find the sun IO tutorial? Can you post a link?
-
Sure, but I recommend that you bookmark this page: The Really Big Index
The specific link is here: Lesson: Basic I/O
- 11-17-2008, 04:41 AM #5
Member
- Join Date
- Nov 2008
- Posts
- 67
- Rep Power
- 0
Thank you so much for that really big index link. I'm going to spend a good chunk of time in the next few days, going over a few of the topics. I've been looking for this kind of thing for a while and now I've found it :)
-
Similar Threads
-
find and replace text from a text file
By gezzel in forum New To JavaReplies: 2Last Post: 09-19-2008, 04:04 PM -
How to Read data from text file and calculate the values?
By janeansley in forum New To JavaReplies: 40Last Post: 07-04-2008, 08:41 AM -
How to read a text file from a Java Archive File
By Java Tip in forum Java TipReplies: 0Last Post: 02-08-2008, 09:13 AM -
Read file
By tajinvillage in forum Threads and SynchronizationReplies: 0Last Post: 01-29-2008, 09:10 AM -
read txt file
By sureshsri1981 in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 08-05-2007, 03:49 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks