: : I've been able to resolve the blank line issue, however, when the
: : data outputs the line reading "ASC Number Loan ID
: : DelqMessage" first. This causes the output to read like:
: :
: : Rundate ASC Loan Delq Message
: : 4/25/07 ASC LoanID elqMessage
: : 4/25/07 033 0001010000 N
: :
: : I do not want that 1st line to output with the ASC LoanID
: : elqMessage. I created an array that is suppose to process all of the
: : junk lines, ie report lines I do not want in th final output.
: : However, I continue to get the following errors:
: :
: : FileParse.java:91: cannot find symbol
: : symbol : variable junkRow
: : location: class FileParse
: : for(int i = 0; i < junkRow.length();i++) {
: : ^
: : FileParse.java:92: cannot find symbol
: : symbol : variable junkRow
: : location: class FileParse
: : if(x.indexOf(junkRow[i])) {
: : ^
: :
: : Here is what I have coded which should be correct:
: :
: :
: :
: : import java.io.FileReader;
: : import java.io.FileWriter;
: : import java.io.BufferedReader;
: : import java.io.PrintWriter;
: : import java.io.IOException;
: :
: : public class FileParse {
: : public void main(String[] args) throws IOException {
: :
: : // Variable Declaration
: :
: : boolean procOn;
: : String RunDate = "";
: : BufferedReader inputStream = null;
: : PrintWriter outputStream = null;
: : String [] junkRow;
: : junkRow = new String[6];
: :
: : // Following initializes elements of array
: :
: : 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])){
: : return true;
: : }
: : if(x.trim().length() < 1) {
: : return true;
: : }
: : } return false;
: : }
: : }
: : : :
: :
: : Any help would be appreciated.
: :
: : Thanks
: :
: Change isJunk() to:
:
:
: private boolean isjunk(String x, String[] junkRow)
:
:
: and then add the junkRow to the parameters. Example:
:
:
: isjunk(someString, junkRow)
:
:
:
: To make it a class field move the junkRow definition to between the
: main() and the line containing the class definition:
:
:
: public class FileParse {
:
: private static String[] junkRow;
:
: public void main(String[] args) throws IOException {
: :
: because there is no object instance of FileParse, you need to make
: junkRow static. The word private means that other classes cannot use
: it (see variable scopes for more info).
I tried both ways and when I compiled the program I received the following error:
FileParse.java:92: incompatible types
found : int
required: boolean
if(x.indexOf(junkRow[i])) {
^
I just do not get it. Everytime I fix something anothr issue pops up on me.
Thanks