Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-26-2008, 11:28 AM
jazz2k8's Avatar
Senior Member
 
Join Date: Apr 2008
Posts: 112
jazz2k8 is on a distinguished road
Output Problem
Quote:
Purchase Items
Order 458
Invoice No

Date Bill noBill DateDescriptionPurpose Qty Rate/unitAmt Remark
12/05/05 152 11/06/08 abc xyz 12 15 250 Abcef
11/05/05 2561 12/07/08 wtc prvn 25 2 2530 good
12/05/05 8695 05/05/08 pen Abcd 12 21 24 Bad
12/05/08 8956 06/05/08 Pencil Drawing 5 2 10 good

Team member: 5 Authorised By: praveen
Employee ID & Signature: 1478 praveen Signature
Team Leader: abcd Accountant:ramu
Received Date:12/05/08
I am in need of
Quote:
12/05/05 152 11/06/08 abc xyz 12 15 250 Abcef
11/05/05 2561 12/07/08 wtc prvn 25 2 2530 good
12/05/05 8695 05/05/08 pen Abcd 12 21 24 Bad
12/05/08 8956 06/05/08 Pencil Drawing 5 2 10 good
But as per My code out put is this format
Quote:
12/05/05 152 11/06/08 abc xyz 12 15 250 Abcef
11/05/05 2561 12/07/08 wtc prvn 25 2 2530 good
12/05/05 8695 05/05/08 pen Abcd 12 21 24 Bad
12/05/08 8956 06/05/08 Pencil Drawing 5 2 10 good
Team member: 5 Authorised By: praveen
Employee ID & Signature: 1478 praveen Signature
Team Leader: abcd Accountant: ramu
Received Date:12/05/08
My code
Quote:
class purchasevchr {

public static String inputFile = "purchase.txt";//Input file
purchase pfr = new purchase();

public void formatFile() {
{

try {
FileInputStream in = new FileInputStream(inputFile);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;

String regEx1 = "(\\d+/)";//date format is matched here
Pattern regEx1P = Pattern.compile(regEx1);


while ((strLine = br.readLine()) != null) {

System.out.println(strLine);//line by line printing
}

} catch (Exception e) {
System.out.println("Exception " + e);
}
}

}

public class sample{

public static void main(String args[]){
purchasevchr ob=new purchasevchr();
ob.formatFile();
}
}
i tried with the code
Quote:
/*


import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class expense1 {

public static String inputFile = "expense.txt";

public void formatFile() {

try
{
FileInputStream in = new FileInputStream(inputFile);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;

String regEx1 = "([0-9]/)";
Pattern regEx1P = Pattern.compile(regEx1);

System.out.println("Date " + "Bill " + "noBill" + "DateDescription" + " Purpose" +
"Qty" + "Dist " + "Rate/unitAmt" + "Remark");

while((strLine = br.readLine())!= null)
{
Matcher match1 = regEx1P.matcher(strLine);

if (match1.find())
{
System.out.println(strLine);
}

//System.out.println(strLine);
}
}
catch (Exception e)
{
System.out.println("Ouch! " + e);
}
}

public static void main(String[] args) {
expense1 exp = new expense1();
exp.formatFile();

}
}
output i am getting is:
Quote:
Date Bill noBillDateDescription PurposeQtyDist Rate/unitAmtRemark
12/05/05 152 11/06/08 abc xyz 12 15 250 Abcef
11/05/05 2561 12/07/08 wtc prvn 25 2 2530 good
12/05/05 8695 05/05/08 pen Abcd 12 21 24 Bad
12/05/08 8956 06/05/08 Pencil Drawing 5 2 10 good
Received Date:12/05/08
at the end i am also getting the "Received Date:12/05/08".i dnt want this

can you help me in this..

thanks in advance.
__________________
visit :
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-26-2008, 11:38 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,376
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Try to find the patter on xx/xx/xx in each string and get the whole string as output.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 05-26-2008, 12:36 PM
jazz2k8's Avatar
Senior Member
 
Join Date: Apr 2008
Posts: 112
jazz2k8 is on a distinguished road
Thats wat i did but ..the issue with the Date Format..it is also taking the
"Received Date:12/05/08"...even i ried with string split('' ");but no use..

can you help me in this
__________________
visit :
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 05-26-2008, 12:40 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,376
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Use the split on first space. In that case you can skip Data and Received from string.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 05-26-2008, 12:59 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,376
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
If the way you have formated the date is fix, you can use following code.

Code:
public void formatFile() { try { FileInputStream in = new FileInputStream(inputFile); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String strLine; String regEx1 = "([0-9]/)"; Pattern regEx1P = Pattern.compile(regEx1); System.out.println("Date " + "Bill " + "noBill" + "DateDescription" + " Purpose" + "Qty" + "Dist " + "Rate/unitAmt" + "Remark"); while((strLine = br.readLine())!= null) { Matcher match1 = regEx1P.matcher(strLine); if (match1.find()) { getFirstPart(strLine); } //System.out.println(strLine); } } catch (Exception e) { System.out.println("Ouch! " + e); } } private void getFirstPart(String str) { if(str.charAt(2) == '/') { System.out.println(str); } }
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
No output displaying Rgfirefly24 New To Java 6 04-27-2008 10:37 PM
Why the output is always zero mehrotra.chitij New To Java 12 04-25-2008 06:05 AM
Output problem jvasilj1 New To Java 0 01-31-2008 08:39 PM
output Camden New To Java 3 12-02-2007 12:34 AM
No output shown ai_2007 Advanced Java 4 07-10-2007 11:26 AM


All times are GMT +3. The time now is 12:05 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org