• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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]
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.


 
He got surgery to replace his foot with a pig. He said it was because of this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic