reading a part of a txt file

Reply

Join Date: Mar 2007
Posts: 165
Reputation: mrjoli021 is an unknown quantity at this point 
Solved Threads: 0
mrjoli021 mrjoli021 is offline Offline
Junior Poster

reading a part of a txt file

 
0
  #1
Dec 9th, 2008
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?
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,665
Reputation: Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future 
Solved Threads: 551
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: reading a part of a txt file

 
0
  #2
Dec 9th, 2008
You can use a Scanner or the String.split() function.
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 165
Reputation: mrjoli021 is an unknown quantity at this point 
Solved Threads: 0
mrjoli021 mrjoli021 is offline Offline
Junior Poster

Re: reading a part of a txt file

 
0
  #3
Dec 9th, 2008
String.split(" ") doesnt work. what would the syntax for the tab deliminater be?
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,665
Reputation: Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future 
Solved Threads: 551
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: reading a part of a txt file

 
0
  #4
Dec 9th, 2008
"\t" is the tab character.
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 165
Reputation: mrjoli021 is an unknown quantity at this point 
Solved Threads: 0
mrjoli021 mrjoli021 is offline Offline
Junior Poster

Re: reading a part of a txt file

 
0
  #5
Dec 9th, 2008
it works with 1 part, but when i put it into an arraylist, it wont compile

  1. for (int i = 0; i<FileList.size(); i++)
  2. {
  3.  
  4. System.out.println(FileList.get(i).split("\t"));
  5. }
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,665
Reputation: Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future 
Solved Threads: 551
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: reading a part of a txt file

 
0
  #6
Dec 9th, 2008
Well, I would imagine it told you why as well, rather than simply stating "This won't compile".
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 630 | Replies: 5
Thread Tools Search this Thread



Tag cloud for Java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2010 DaniWeb® LLC