For my Software Engineering class I am required to use maven to create an SVG file. At the moment I have my only java file in main class looking like this:
import java.io.File; // Import the File class
import java.io.FileWriter;
import java.io.IOException; // Import the IOException class to handle errors
public class CreateFile {
public static void main(String[] args) {
try {
File myObj = new File("tester22.svg");
if (myObj.createNewFile()) {
System.out.println("File created: " + myObj.getName());
} else {
System.out.println("File already exists.");
}
} catch (IOException e) {
System.out.println("An error occurred.");
e.printStackTrace();
}
try {
FileWriter myWriter = new FileWriter("tester.svg");
myWriter.write("Files in Java might be tricky, but it is fun enough!");
myWriter.close();
System.out.println("Successfully wrote to the file.");
} catch (IOException e) {
System.out.println("An error occurred.");
e.printStackTrace();
}
}
}
However, when I run maven test
it does not generate the tester22.svg file.
I am not sure how to make it create the file as when I run that java file on its own it has no problem creating the file.
EDIT: when I run mvn test
, everything comes back successful and there seems to be no problems.