tab separated file

Reply

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

tab separated file

 
0
  #1
Nov 18th, 2008
I have a file that is tab separated. i read it in as an arraylist<string> how can i print out only the second section of the file?
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,346
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 498
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: tab separated file

 
0
  #2
Nov 18th, 2008
That depends what "second section" means. If you can't be more specific than that, you have little chance of getting a program to do something with it.
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 144
Reputation: mrjoli021 is an unknown quantity at this point 
Solved Threads: 0
mrjoli021 mrjoli021 is offline Offline
Junior Poster

Re: tab separated file

 
0
  #3
Nov 18th, 2008
the file is tab separated into three sections.

section1 section2 section3

i only want to read section2
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,346
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 498
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: tab separated file

 
0
  #4
Nov 18th, 2008
Then use String.split() to separate it and read the second element of the result.
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 144
Reputation: mrjoli021 is an unknown quantity at this point 
Solved Threads: 0
mrjoli021 mrjoli021 is offline Offline
Junior Poster

Re: tab separated file

 
0
  #5
Nov 18th, 2008
array is an arraylist<string>

  1. for (int i = 0; i<array.size(); i++)
  2. {
  3. System.out.println(array.get(i).split(" "));
  4.  
  5. }

i get: [Ljava.lang.String;@ca0b6

i am supposed to get "10.0.0.2"
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,346
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 498
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: tab separated file

 
0
  #6
Nov 18th, 2008
Did you read the api doc on split() at all?
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 144
Reputation: mrjoli021 is an unknown quantity at this point 
Solved Threads: 0
mrjoli021 mrjoli021 is offline Offline
Junior Poster

Re: tab separated file

 
0
  #7
Nov 18th, 2008
yes and according to the instructions that is how u should use it.
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,346
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 498
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: tab separated file

 
0
  #8
Nov 18th, 2008
Really? Because this particular part would seem to be clearly saying something else
Returns:
the array of strings computed by splitting this string around matches of the given regular expression
Notice the array part.

(Also, there does not appear to be anyone named "u" here at the moment. Use proper English.)
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 144
Reputation: mrjoli021 is an unknown quantity at this point 
Solved Threads: 0
mrjoli021 mrjoli021 is offline Offline
Junior Poster

Re: tab separated file

 
0
  #9
Nov 18th, 2008
i read it again and i still understand the same thing.

i obiously dont understand how to use it.

can you help me out or not.
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,346
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 498
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: tab separated file

 
0
  #10
Nov 18th, 2008
It splits on a particular expression, which in your case should be tab, and returns an array of the pieces. If you want the second section then you just need the second element of that array.
Reply With Quote Quick reply to this message  
Reply

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


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC