File file = new File("plugins/ThisIsThePluginsDirectory/Log.txt"); It throws a java.io.IOException. "java.io.IOException The system was not able to find the specified path" Could you help? Thanks in advance
Try this instead PHP: File file = new File("../ThisIsThePluginsDirectory/Log.txt"); I don't know if it will work, it's just what I would have tried
I get the same error =\ . If this helps at all: Code:java public void writeToFile(String str){ try { File file = new File("../ThisIsAPlugin/Log.txt"); if(file.exists() == false){ file.createNewFile(); } BufferedWriter output = new BufferedWriter(new FileWriter(file, true)); output.write(str); output.newLine(); output.close(); this.getLogger().log(Level.INFO, str); } catch (IOException ex) { Logger.getLogger(ThisIsAPlugin.class.getName()).log(Level.SEVERE, null, ex); } } EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Ahhh, I remember working with files... It was a pain. But it pays. Just pulled this out of ImgMap: Code:JAVA File f = new File(cirno.getDataFolder().getAbsoluteFile(), "\\MapData.list"); cirno is the JavaPlugin class.
Could be possibly that the folder doesn't exist. Got lazy, just copypasta'd my own source. Code:JAVA public void initializeFile() throws IOException{ File f = new File(cirno.getDataFolder().getAbsoluteFile(), "\\MapData.list"); File folder = new File(cirno.getDataFolder().getAbsoluteFile().getAbsolutePath()); if(!folder.exists()){ folder.mkdir(); } if(!f.exists()){ f.createNewFile(); } FileSafeForUse = true; }
notice this dont works on linux, and most server use linux these days, use an "/" for linux (also works on windows)