The Artima Developer Community
Sponsored Link

Java Answers Forum
Help parsing positional flat files

2 replies on 1 page. Most recent reply: Jan 8, 2004 12:02 AM by Julius Malixi

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
Julius Malixi

Posts: 6
Nickname: jmalixi
Registered: Dec, 2003

Help parsing positional flat files Posted: Dec 23, 2003 8:28 AM
Reply to this message Reply
Advertisement
I have a project that requires parsing a positional flat file and would appreciate some sample code if anybody has one. Basically, the app should read a file line by line and parses each line by position.

i.e.

Field1Field2Field3Field4Field5

Field1 starts at offset 0, length 6
Field2 starts at offset 7, length 6
etc.

Each field contains actual values. In addition to this, I will need to attach each value with a specified key, but I'm unsure what the best approach to do this is.

Feedback is greatly appreciated!


mausam

Posts: 243
Nickname: mausam
Registered: Sep, 2003

Re: Help parsing positional flat files Posted: Jan 2, 2004 3:46 AM
Reply to this message Reply
I think..read the file line by line..


FileReader fr = new FileReader("file.text");
BufferedReader first = new BufferedReader(fr);
String line= new String();
while ((line = first.readLine()) !=null)
{

//now take the substring for this line.... from 0 to 6 //(counter) and add 6 to counter for next substring...
}

Julius Malixi

Posts: 6
Nickname: jmalixi
Registered: Dec, 2003

Thanks! Posted: Jan 8, 2004 12:02 AM
Reply to this message Reply
I appreciate the feedback. That's exactly what I ended up doing. I was hoping for something more simplistic, like a union ... but, this will have to do for now! Thanks again!

Flat View: This topic has 2 replies on 1 page
Topic: invoke windows api(i.e:-pdf/doc/ppt exe) Previous Topic   Next Topic Topic: hellllllllppppppp urgent

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use