View Single Post
  #5 (permalink)  
Old 05-12-2008, 12:59 PM
jazz2k8's Avatar
jazz2k8 jazz2k8 is offline
Member
 
Join Date: Apr 2008
Posts: 87
jazz2k8 is on a distinguished road
Quote:
public class TabData2 {

static String Sno,Qty,Description,Unit,Rate,Value;
public static void main(String args[]) throws FileNotFoundException{
File file = new File("D:\\bharath\\CSV\\tab2.txt");
StringBuilder sb = new StringBuilder();
Scanner scanner = new Scanner(file);
while (scanner.hasNextLine()) {
// String line = scanner.nextLine();
// while(scanner.hasNext()){
Sno = scanner.next();
Description = scanner.next();
Qty = scanner.next();
Unit = scanner.next();
Rate = scanner.next();
Value = scanner.next();
Formatter fmt=new Formatter();
fmt.format("%s\n",Sno);
fmt.format("%s\n",Description);
fmt.format("%s\n",Qty);
fmt.format("%s\n",Rate);
fmt.format("%s\n",Value);


System.out.println(Sno);
System.out.println(Description);
System.out.println(Qty);
System.out.println(Rate);
System.out.println(Value);

}

}
}
i AM GETING ERRORS:My Output is:

sno
Description
Qty.
Rate
(Rs.)
Value
(Rs.)
1
Lamp
1
Nos
3700
3,700
Lighting
Arrester
1
Nos
1600
3
Aviataion
Lamp
Cable
31
270
8,370
Gross
Total
13,670
above
Total
include
Services
Tax
of
Rs
536
Total
Invoice
I
13,670
Now
Claimed
100%
Invoice
Value
13,670
(Rupees
Thirteen
Six
Hundred
and
Seventy
only)
Description
Qty.
Rate
(Rs.)
Value
1
Lamp
1
Nos
3700
Lighting
Arrester
1
Nos
1600
Aviataion
Lamp
Cable
31
270
Gross
Total
13,670
above
Total
Services
Tax
of
Rs
536
Invoice
I
13,670
Now
Claimed
Invoice
Value
Exception in thread "main" java.util.NoSuchElementException
at java.util.Scanner.throwFor(Scanner.java:838)
at java.util.Scanner.next(Scanner.java:1347)
at TabData2.main(TabData2.java:31)



any one correct this..please..thnx...My desired output is :

S.No 1
Description Aviation Lamp
Qty. 1
Units Nos
Rate (Rs.) 3700
Value (Rs.) 3700

S.No 2
Description Lighting Arrester
Qty.1
Units Nos
Rate (Rs.) 1600
Value (Rs.) 1600

S.No 3
Description Aviataion Lamp Cable
Qty.31
Units Nos Rmt
Rate (Rs.) 270
Value (Rs.) 8,370

Gross Total 13,670
Tax Amount of Rs 536
Total Invoice Value 13,670
__________________
visit :
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Reply With Quote