I'm writing this class that has a method to create a csv file and to write in to it. The problem is that it throws IOException
error before the file is even created.
This is a class on its own, and the method is being called from another class.
The code looks like this:
public class WriteCSV {
public WriteCSV () {
}
public void writeToFile(Movie movie) {
try {
BufferedWriter out = new BufferedWriter(new FileWriter("ratings.csv"));
out.write(movie.getId() +";" + movie.getTitle() + ";" + movie.getDuration() +";" + movie.getImg() + ";" + movie.getStars());
out.close();
}
catch (IOException ex) {
System.out.println("Error");
}
}
}