The Artima Developer Community
Sponsored Link

Java Answers Forum
Reading flat files from java which has no delimiters

6 replies on 1 page. Most recent reply: Dec 30, 2002 12:50 AM by Matt Gerrans

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 6 replies on 1 page
Telkapallin Nalini

Posts: 2
Nickname: nallu
Registered: Dec, 2002

Reading flat files from java which has no delimiters Posted: Dec 19, 2002 9:29 PM
Reply to this message Reply
Advertisement
hi

I have a problem in reading a flat file from java. I am having DAT file created by cobol program. It contains employees information. Problems is it does not have delimiters.But has fixed length of data in columns.

DAT File format is as follows

000123 Scott009000
000124 James013000

First column is EmpId size 6(Incl. zeros)
Second column is EmpName size 8(Incl. spaces)
Third column is Salary size is 6(Incl. zeros)

Pl. look to this problem

regards
Nallu


Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: Reading flat files from java which has no delimiters Posted: Dec 20, 2002 3:12 PM
Reply to this message Reply
Hmm. Seems pretty simple. Look at String.substring().

Trex Lim

Posts: 3
Nickname: trexlim
Registered: Dec, 2002

Re: Reading flat files from java which has no delimiters Posted: Dec 22, 2002 8:44 PM
Reply to this message Reply
Telkapallin Nalini:
I think there should be two processing involved to extract each field, which are extracting record (row), then the field.
In fact, there is a deliminator for each row (that is carriage return (\n)). While your field is deliminated by length.
What I did for my project was to read each row using readLine(). Then, like what the other reply suggested, use substring(begin, end) to extract each field.
I hope this will help.

Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: Reading flat files from java which has no delimiters Posted: Dec 24, 2002 3:18 PM
Reply to this message Reply
By the way, the word is delimiter not deliminator (unless you are Arnold Schwarzenegger).

Trex Lim

Posts: 3
Nickname: trexlim
Registered: Dec, 2002

Re: Reading flat files from java which has no delimiters Posted: Dec 25, 2002 6:27 PM
Reply to this message Reply
Matt Gerrans:
Thanks for the correction. I tend to make the mistake. All the best!

hamdan

Posts: 1
Nickname: hamdan
Registered: Dec, 2002

Re: Reading flat files from java which has no delimiters Posted: Dec 27, 2002 10:38 PM
Reply to this message Reply
yar

; <-- this thing in
Java is called delimiter or deliminator
And why it is called so.

Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: Reading flat files from java which has no delimiters Posted: Dec 30, 2002 12:50 AM
Reply to this message Reply
Ah ha. I suppose you call your computer a computer or a computator, as well.

Flat View: This topic has 6 replies on 1 page
Topic: Create new database problem Previous Topic   Next Topic Topic: servlets, jdbc

Sponsored Links



Google
  Web Artima.com   

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