Results 1 to 3 of 3
  1. #1
    adlb1300 is offline Member
    Join Date
    Jul 2007
    Posts
    46
    Rep Power
    0

    Default 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.


    Java 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

  2. #2
    JavaBean's Avatar
    JavaBean is offline Moderator
    Join Date
    May 2007
    Posts
    1,270
    Rep Power
    9

    Default

    The definition of main method should be like this:

    Java Code:
    public static void main(String args[])
    So you forgot static keyword there!

  3. #3
    adlb1300 is offline Member
    Join Date
    Jul 2007
    Posts
    46
    Rep Power
    0

Similar Threads

  1. newbie needs help...
    By vicky08 in forum New To Java
    Replies: 2
    Last Post: 03-31-2008, 04:26 PM
  2. Newbie
    By CSnoob87 in forum Introductions
    Replies: 2
    Last Post: 02-18-2008, 08:49 AM
  3. Newbie in applet, Help me
    By barney in forum Java Applets
    Replies: 1
    Last Post: 08-07-2007, 07:14 AM
  4. newbie: the app is loaded but i can't see it
    By tamayo in forum New To Java
    Replies: 1
    Last Post: 07-21-2007, 08:14 AM
  5. MultipartRequest File Upload parser 2.0B9
    By levent in forum Java Software
    Replies: 0
    Last Post: 05-12-2007, 12:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •