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 07-23-2007, 06:45 AM
Member
 
Join Date: Jul 2007
Posts: 46
adlb1300 is on a distinguished road
Newbie help with a file parser
I'm new to Java and I'm trying to create a file parser that reads through a text file and outputs certain lines to another text file with tab delimited spaces btween th data. The following is an example of the file I'm trying to parse:

Report: Fake Report for Fake Loans
Report ID: 000001
Run Date: 04/25/2007
----------------------------------------------------------------------
ASC Number Loan ID DelqMessage
033 000101000 N
034 001234875 Y
035 123456789 N

----------------------------------------------------------------------
ASC Number Loan ID DelqMessage
036 741258963 N
037 872563987 N
038 987521455 Y

================================================== ====================

Fake Report Summary:
ASC Total: 6
Loan Total: 6
Total Delq: 2

The output would like the following:

Rundate ASC LoanId Delq Message
4/25/07 031 1234567891 N

When I try to run the program I get the following error:

Exception in thread "main" java.lang.NoSuchMethodError: main

Anybody have any suggestions on what I need to do to resolve this error. Below is my current code.


Code:
import java.io.FileReader; import java.io.FileWriter; import java.io.BufferedReader; import java.io.PrintWriter; import java.io.IOException; public class FileParse { private static String[] junkRow; public void main(String[] args) throws IOException { // Variable Declaration boolean procOn; String RunDate = ""; BufferedReader inputStream = null; PrintWriter outputStream = null; junkRow = new String[6]; junkRow[0] = "Report"; junkRow[1] = "ASC Number"; junkRow[2] = "Fake Report"; junkRow[3] = "Loan Total"; junkRow[4] = "Total Delq"; junkRow[5] = "ASC Total"; // Following block of cod parses FakeReportToParse.txt and outputs // needed portions of the report to characteroutput.txt try { procOn = false; inputStream = new BufferedReader(new FileReader("FakeReportToParse.txt")); outputStream = new PrintWriter(new FileWriter("characteroutput.txt")); outputStream.println("Rundate\tASCNumber\tLoan\tDelqMessage"); String l; while ((l = inputStream.readLine()) != null) { if (l.indexOf("Run Date:") >= 0) { RunDate = l.substring(10); } // Processing of report data if(l.indexOf("ASC Number") >= 0) { procOn = true; } if(l.indexOf("---") >= 0 || l.indexOf("===") >= 0) { procOn = false; } // Output report data to new characteroutput.txt file if(procOn) { if(!isjunk(l)) { String ASC = l.substring(0, 4).trim(); String LoanID = l.substring(15, 25).trim(); String DelqM = l.substring(30).trim(); { outputStream.println(RunDate + "\t" + ASC + "\t" + LoanID + "\t" + DelqM); } } } } } catch(Exception z){ System.out.println("Error: " + z.toString()); } finally { if (inputStream != null) { inputStream.close(); } if (outputStream != null) { outputStream.close(); } } } // @return true if it's a junk row // @return false if it's not private boolean isjunk(String x){ for(int i = 0; i < junkRow.length;i++){ if(x.indexOf(junkRow[i]) >= 0) { return true; } if(x.trim().length() < 1) { return true; } } return false; } }
Thanks for your help
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-23-2007, 10:15 AM
JavaBean's Avatar
Moderator
 
Join Date: May 2007
Posts: 1,272
JavaBean is on a distinguished road
The definition of main method should be like this:

Code:
public static void main(String args[])
So you forgot static keyword there!
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-24-2007, 06:31 AM
Member
 
Join Date: Jul 2007
Posts: 46
adlb1300 is on a distinguished road
Thanks JavaBean. It works.
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
newbie needs help... vicky08 New To Java 2 03-31-2008 06:26 PM
Newbie CSnoob87 Introductions 2 02-18-2008 10:49 AM
Newbie in applet, Help me barney Java Applets 1 08-07-2007 09:14 AM
newbie: the app is loaded but i can't see it tamayo New To Java 1 07-21-2007 10:14 AM
MultipartRequest File Upload parser 2.0B9 levent Java Announcements 0 05-12-2007 02:24 PM


All times are GMT +3. The time now is 11:28 AM.


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