943,923 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 938
  • Java RSS
Dec 9th, 2008
0

reading a part of a txt file

Expand Post »
I have a tab delimilated txt file. how can i read only the second part of the file. ex

10.0.0.0 hostname date

i want to read in the hostname only

what function can i use to do this?
Similar Threads
Reputation Points: 7
Solved Threads: 0
Junior Poster
mrjoli021 is offline Offline
170 posts
since Mar 2007
Dec 9th, 2008
0

Re: reading a part of a txt file

You can use a Scanner or the String.split() function.
Moderator
Featured Poster
Reputation Points: 3239
Solved Threads: 839
Posting Genius
Ezzaral is offline Offline
6,761 posts
since May 2007
Dec 9th, 2008
0

Re: reading a part of a txt file

String.split(" ") doesnt work. what would the syntax for the tab deliminater be?
Reputation Points: 7
Solved Threads: 0
Junior Poster
mrjoli021 is offline Offline
170 posts
since Mar 2007
Dec 9th, 2008
0

Re: reading a part of a txt file

"\t" is the tab character.
Moderator
Featured Poster
Reputation Points: 3239
Solved Threads: 839
Posting Genius
Ezzaral is offline Offline
6,761 posts
since May 2007
Dec 9th, 2008
0

Re: reading a part of a txt file

it works with 1 part, but when i put it into an arraylist, it wont compile

Java Syntax (Toggle Plain Text)
  1. for (int i = 0; i<FileList.size(); i++)
  2. {
  3.  
  4. System.out.println(FileList.get(i).split("\t"));
  5. }
Reputation Points: 7
Solved Threads: 0
Junior Poster
mrjoli021 is offline Offline
170 posts
since Mar 2007
Dec 9th, 2008
0

Re: reading a part of a txt file

Well, I would imagine it told you why as well, rather than simply stating "This won't compile".
Moderator
Featured Poster
Reputation Points: 3239
Solved Threads: 839
Posting Genius
Ezzaral is offline Offline
6,761 posts
since May 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Passing by "reference" - how to change primitive type in a function
Next Thread in Java Forum Timeline: Get File creation Date





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC