I am currently working on a vehicular cloud program that takes client information and takes vehicle owner information and stores them in separate .csv files. I am using an array to separate each object making it easier to put in the csv file but the problem is, when ever i run through the program it executes but does not write to file. I use a submit button to store the info in an array that allows for later use when writing to the file. I tried not using the direct path to the file as well ex.("ownerLog.csv")
-SubmitButton code
private void submit2ActionPerformed(java.awt.event.ActionEvent evt) {
String timeStamp = new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss").format(new Date());
String[] tempArr = {OID.getText(), VModel.getText(), (String)Vehcolors.getSelectedItem(),
vplate.getText(), (String)Rday.getSelectedItem(), (String)RMonths.getSelectedItem(), timeStamp};
//adding the temporary data array to the total client entries for file writing at later point
ownerEntries.add(tempArr);
-Write to .csv file code
try {
try (FileWriter csvWriter = new FileWriter("C:\\Users\\juals\\Documents\\NetBeansProjects\\GUIFormExamples\\src\\ownerLog.csv")) {
csvWriter.append("Owner id");
csvWriter.append(",");
csvWriter.append("Vehicle Model");
csvWriter.append(",");
csvWriter.append("Vehicle Color");
csvWriter.append(",");
csvWriter.append("Vehicle Plate Number");
csvWriter.append(",");
csvWriter.append("Approx. Residency Days");
csvWriter.append(",");
csvWriter.append("Approx Residency Months");
csvWriter.append(",");
csvWriter.append("Timestamp");
csvWriter.append("\n");
for(String[] entry: ownerEntries) {
System.out.println(String.join(",", entry));
csvWriter.append(String.join(",", entry));
csvWriter.append("\n");
}
}
} catch (IOException e) {
e.printStackTrace();
}