• Post Reply Bookmark Topic Watch Topic
  • New Topic

reading a text file that has field positions(without delimiters)and insert into table  RSS feed

 
chaitanya kamala
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

i have a requirement to read a text file where field positions are specified and make use of that data to insert into tables. Please refer to the data in the text file below

1234 HEDEPT 12-3-2009 12-03-2009 yesno yes A hello@hello.com 12 y12
1234 HEDEPT 12-3-2009 12-03-2009 yesno yes A hello@hello.com 12 y12

i am reading the text file using Filereader . please help me how to read the same making use of field positions.
emp id 1-4[fieldposition]
deptcode 4-12[fieldposition]
 
Rob Spoor
Sheriff
Posts: 20895
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

Have you looked at the Javadoc for java.lang.String? There are some nice methods there that returns a portion of a String. Now all you need to do is read the file line by line (wrap your FileReader in a BufferedReader or a LineNumberReader, then use readLine()) and then take out the right portions of each line.
 
subhash kumar
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

1234 HEDEPT 12-3-2009 12-03-2009 yesno yes A hello@hello.com 12 y12
1234 HEDEPT 12-3-2009 12-03-2009 yesno yes A hello@hello.com 12 y12


here i thing space can be use as delimiter.


 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!