• Post Reply Bookmark Topic Watch Topic
  • New Topic

string parsing  RSS feed

 
Rick Jones
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

I have a fairly large data file with about 13 columns. I only want to show about 3 of them. What would be the best way to go about that?

Thanks!
 
Steve Morrow
Ranch Hand
Posts: 657
Clojure Spring VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read the file line by line, parsing the strings into a collection of objects that contain the information you need.
 
Rick Jones
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any examples? I'm fairly new

Thanks!
 
Kishore Dandu
Ranch Hand
Posts: 1934
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rick Jones:
Any examples? I'm fairly new

Thanks!


We try to help on posted code(basically your own code). Not give code snippets that are used like in class projects.
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you should look at the String and StringTokenizer classes. You may also want to look at the classes available in the java.util.regex package. There are plenty of examples available in the Java Tutorial, API docs, and elsewhere online so we shouldn't need to repeat them here. Try using Google if you don't know how to find them.

Layne
 
Sathya Srinivasan
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if you are looking at a database, take a look at the methods in the ResultSet class. If you are reading things from a file (like a CSV or tab-delimited), try looking at the methods in the StringTokenizer class.

One thing you should definitely do to move from 'freshman' to 'sophomore' is to know how to read the Java API. That's a bare minimum. The more you get familiarized with it, the more comfortable you will be with Java.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!