about reading content out of the file

here is the pattern of the file i wanna get the content out.

--------------------------------------------------------------------------------------------------------
0,aldeg_cas01.gat,Noisy ubantian,1
1,aldeg_cas02.gat,Hohensyubangawoo,1
2,aldeg_cas03.gat,Nyir enverk,1
3,aldeg_cas04.gat,Byirts buri,1
--------------------------------------------------------------------------------------------------------

i wanna know the most efficiency method to get the content out of this kind of file.
should i just use array? or s.t else?
and another problem , will the space in the 3rd column b any problme if i didn't use string for that?

can any1 suggest me a good code for doing this?

tom_mkAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

zzynxSoftware engineerCommented:
Read line by line (String) and split up the line in its components using line.split(",")
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
objectsCommented:
BufferedReader in = new BufferedReader(new FileReader("file.txt"));
String line = null;
while (null!=(line=in.readLine()))
{
   String[] tokens = line.split(",");
   // use data as required
}
in.close();
0
zzynxSoftware engineerCommented:
try {
        BufferedReader in = new BufferedReader(new FileReader("<your file>"));
        String line;
        while ((line = in.readLine()) != null) {
            String parts[] = line.split(",");
            for (int i=0; i<parts.length; i++)
               System.out.println(parts[i]);
        }
        in.close();
    } catch (IOException e) {
    }

>> will the space in the 3rd column b any problme if i didn't use string for that?
???
The content of your file is String, isn't it?
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

tom_mkAuthor Commented:
thx guys... very fast..

another sub question

says, in my file
i have some comment on top, just wanna put there .
and i need my prog to ignore that part while reading thru my file

how can i do that?
below is the example

thxxx very much

-------------------------------------------
//ƒMƒ‹ƒhéƒf[ƒ^ by sakage,shuto
// AgitDB Modify by Michael_Huang at 2004-02/13.
// <Castle_ID>,<Map_Name>,<Castle_Name>,<Switch_Flag:(reserved)>
0,aldeg_cas01.gat,Noisyubantian,1
1,aldeg_cas02.gat,Hohensyubangawoo,1
2,aldeg_cas03.gat,Nyirenverk,1
3,aldeg_cas04.gat,Byirtsburi,1
4,aldeg_cas05.gat,Rotenburk,1
5,gefg_cas01.gat,Reprion,1
0
zzynxSoftware engineerCommented:
try {
        BufferedReader in = new BufferedReader(new FileReader("<your file>"));
        String line;
        while ((line = in.readLine()) != null) {
            if (line.startsWith("//") continue; // <<<<<<<<<<<<<<<<<<<
            String parts[] = line.split(",");
            for (int i=0; i<parts.length; i++)
               System.out.println(parts[i]);
        }
        in.close();
    } catch (IOException e) {
    }
0
objectsCommented:
if (line.startsWith("//"))
{
   // ignore
}
else
{
  ...
}
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.