View Single Post
  #3 (permalink)  
Old 05-09-2008, 04:07 PM
sukatoa's Avatar
sukatoa sukatoa is offline
Senior Member
 
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 508
sukatoa is on a distinguished road
Send a message via Yahoo to sukatoa
Given the contents of a.txt...

You should get some patterns there.

If the example you've given is like the quote below,

Quote:
S.No Description Qty. Units Rate (Rs.) Value(Rs.)
1 Aviation_Lamp 1 Nos 3700 3,700
2 Lighting_Arrester 1 Nos 1600 1,600
3 Aviataion_Lamp_Cable 31 Rmt 270 8,370
You can use Scanner class for this.

Code:
while(scannerObject.hasNext()){ s.no = scannerObject.next(); description = scannerObject.next(); qty = scannerObject.next(); unit = scannerObject.next(); rate = scannerObject.next(); value = scannerObject.next(); print those values.... }
Try to have some experiments from it....
(Printing on console may be a good tests)

After that, read the Formatter class....
You can format it like the format you've post...

Code:
Formatter.format("%s\n", String);
__________________
A specific, detailed, simple, well elaborated, and "tested before asking" question may gather more quick replies. hopefully
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Last edited by sukatoa : 05-09-2008 at 04:12 PM. Reason: Additional.....
Reply With Quote