adamhutton
IS-IT--Management
I've built a simple program to modify a csv file depending on various conditons. The program works great in the NetBeans and JCreator compilers and runs great in both of them. It will compile using javac but it will not run for anything using java at the command line.
It's getting an "Exception in thread 'main' java.lang.NoSuchMethodError"
I'm stumped on this. Anybody have any ideas?
:Code:
/**
* Code Modifies records in a CSV file
* in the event of finding a "D/O" in a
* row.
*/
import java.io.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
public class ListMod{
/**
* Creates a new ListMod object
*/
public static void main(String[] args){
new ListMod();
}
/**
* Creates the GUI
*/
public ListMod(){
//create the GUI
//call mod
modCSV("sale.csv", "output.csv");
}
/**
* modCSV, method to perform the work on the csv file.
*
* @param in the file to read from
* @param out the file to write to
*/
public void modCSV(String in, String out){
int leaseCount = 0; //holds a count of leased vehicles
String str;
boolean isLeased = false;
try{
BufferedReader br = new BufferedReader(new FileReader(in));
BufferedWriter bw = new BufferedWriter(new FileWriter(out));
while((str = br.readLine()) != null){
String line = "";
//split up the row in by commas
String stArray[] = str.split(",");
//loop through each cell
for(int x = 0; x<stArray.length; x++){
stArray[x] = stArray[x].trim();
if(stArray[x].indexOf("D/O") != -1){
stArray[x] = stArray[x].replaceAll("D/O", "");
stArray[18] = "1";
}
//add the cell to the row
line = line + stArray[x] + ",";
}
//write the row to the file
bw.write(line+"\n");
} //end while to loop through the rows
//close the files
br.close();
bw.close();
} //end try
catch(IOException ioe){
ioe.printStackTrace();
}
} //end modCSV
} //end class
It's getting an "Exception in thread 'main' java.lang.NoSuchMethodError"
I'm stumped on this. Anybody have any ideas?
:Code:
/**
* Code Modifies records in a CSV file
* in the event of finding a "D/O" in a
* row.
*/
import java.io.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
public class ListMod{
/**
* Creates a new ListMod object
*/
public static void main(String[] args){
new ListMod();
}
/**
* Creates the GUI
*/
public ListMod(){
//create the GUI
//call mod
modCSV("sale.csv", "output.csv");
}
/**
* modCSV, method to perform the work on the csv file.
*
* @param in the file to read from
* @param out the file to write to
*/
public void modCSV(String in, String out){
int leaseCount = 0; //holds a count of leased vehicles
String str;
boolean isLeased = false;
try{
BufferedReader br = new BufferedReader(new FileReader(in));
BufferedWriter bw = new BufferedWriter(new FileWriter(out));
while((str = br.readLine()) != null){
String line = "";
//split up the row in by commas
String stArray[] = str.split(",");
//loop through each cell
for(int x = 0; x<stArray.length; x++){
stArray[x] = stArray[x].trim();
if(stArray[x].indexOf("D/O") != -1){
stArray[x] = stArray[x].replaceAll("D/O", "");
stArray[18] = "1";
}
//add the cell to the row
line = line + stArray[x] + ",";
}
//write the row to the file
bw.write(line+"\n");
} //end while to loop through the rows
//close the files
br.close();
bw.close();
} //end try
catch(IOException ioe){
ioe.printStackTrace();
}
} //end modCSV
} //end class