Meaningless Drivel is fun!*
The moose likes I/O and Streams and the fly likes how to take values in  txt file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "how to take values in  txt file " Watch "how to take values in  txt file " New topic
Author

how to take values in txt file

mohan cheepu
Ranch Hand

Joined: Nov 15, 2007
Posts: 49
Hi

i am facing problem that take values from txt file. See below format of txt.

PO#: ME34E176955 COR DT: 04/12/10
SO#: FO2046AQ BUYER: MITZI DEL CONSUELO,ESPARZA
DIST END PO: FSI SOLD TO: VASCI
CUST SOLD TO: OPT SOLD TO IDT:
CUST SHIP TO: OPT SHIP TO IDT:
RECVD DT: / / RECVD TM: : : CONFIRM? Y CUR: REG: FO
PA#: PURP CODE: CONFIRM CUST CONTRACT#:


POI: 1 MPN: S9S12C64J2VFUE CPN: VLGB000039250
REV: 001 PKG:
CUST CONTRACT#:
PA#: CHG TYPE: CH
POI ERRORS: 3YB

LI DL TYPE REQ CRD REQ QTY PRICE CITI ERROR(S)
== == ==== ======= =========== ============= =============== ================
01 01 COR 29SEP10 1176 2.780000
01 01 CURR 29SEP10 1176 2.780000



Using StringTokenzer take values which are horizontal.ex: PO#, COR DT: .

But i amnot able to take values of tabular form .

See below code :

fis = new FileInputStream(file);


BufferedReader bis=new BufferedReader(new InputStreamReader(fis));


String Line;
while ( null !=(Line=bis.readLine())){

StringTokenizer st=new StringTokenizer(bis.readLine());
while(st.hasMoreTokens())
{
String word=st.nextToken();
if(word.equals("FSA:"))
{
word=st.nextToken();
List l=new ArrayList();
l.add(word);

}


}


.Please tell me any one how can i do .

Thanks
Mohan

Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
Please enclose the code part of your post in Code Tags.

The readLine() method would always read one full line from a text file. I think you have to make it into a tabular form yourself by manipulating what come from the readLine().
mohan cheepu
Ranch Hand

Joined: Nov 15, 2007
Posts: 49

I tried but i didnt get. If possible write peace of code.

Thanks
Mohan
Martin Vanyavchich
Ranch Hand

Joined: Sep 16, 2008
Posts: 241


try changing to:



SCJP 6, OCMJD 6, OCPJWSD 6
I no good English.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to take values in txt file