I am trying to achieve inputting n number of parameters as arguments to the java main function.
From these n parameters, n-1 of them are input file and the nth one is output file.
public static void main(String[] args) {
List<String> stringList = new ArrayList<String>();
String xlsxFileAddress;
for (int i = 0; i < args.length - 1; i++) {
stringList.add(args[i].toString());
}
String[] csvFileAddress = (String[]) stringList.toArray();
xlsxFileAddress = args[args.length - 1];
for (int i = 0; i < 2; i++) {
System.out.println(csvFileAddress[i]);
}
System.out.println(xlsxFileAddress);
csvToXLSX(csvFileAddress, xlsxFileAddress);
}
But this is throwing the following error -
Exception in thread "main" java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.String;
at com.jcg.csv2excel.CsvToExcel.main(CsvToExcel.java:109)