Here is my project structure
DejaVuu
-- src/main/java
---- views
------ basetheme.css
-- src/test/java
-- src
-- basetheme.css
-- tempfile.css
Currently I am trying to read in my css file with
view.getStylesheets().add("basetheme.css");
But this does not work. However, it works when I use
view.getStylesheets().add("views/basetheme.css");
I need basetheme.css at the root because that is where I rewrite the file to after some updates. In other words, the read and write location should be the same.
Here is the code I call to write to the file:
public String writeToCSS(String css) throws IOException {
String path_name = "basetheme.css"; // I need this to match read in for getStyleSheet().add
File temp = new File(path_name);
temp.delete();
temp.createNewFile();
BufferedWriter bw = new BufferedWriter(new FileWriter(temp));
bw.write("some css");
bw.close();
String temp_url = temp.toURI().toString();
return temp_url;
}
Now when looking in writeToCSS
and the following is set
String path_name = "basetheme.css";
the above writing works. This is to root of project. The issue is that now I cannot read the stylesheet into JavaFX from this location.
With that said, I have tried to write the file to
String path_name = "/home/ming/eclipse-workspace/DejaVuu/views/basetheme.css";
However, I receive an error when doing this
java.io.IOException: No such file or directory
java.io.UnixFileSystem.createFileExclusively(Native Method)
java.io.File.createNewFile(File.java:1012)
Can File
not be used to write to packages in MavenProjects?