| | |
Class File, making directories... relative to
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
That's indeed the method you want, but most likely you're not calling it correctly.
Without knowing what you're doing and what's happening as a result it's impossible to say more than that.
Without knowing what you're doing and what's happening as a result it's impossible to say more than that.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
OK this works, i forgot to add the "\\" at the end of the file argument
also worked out that if you want a relative path i just need to remove the "C:" so it would be like this \\tmpfolder\\ :cheesy:
Java Syntax (Toggle Plain Text)
import java.io.File; public class testFile { public static void main(String[] args) { File file = new File("C:\\tmpFolder\\"); System.out.println(file.mkdir()? "success" :"failed"); } }
also worked out that if you want a relative path i just need to remove the "C:" so it would be like this \\tmpfolder\\ :cheesy:
---
Wasps
Wasps
That's correct. And if you want to create a complete directory path even if parts don't exist, use mkDirs.
Some advise though: don't hardcode path separators. Use the system property "path.separator" instead to make your code platform independent (and of course always use relative paths to some system property).
Some advise though: don't hardcode path separators. Use the system property "path.separator" instead to make your code platform independent (and of course always use relative paths to some system property).
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
mkDirs will create the entire path you pass it, including non-existent directories.
So if you pass it "/usr/myapp/data/20060407/xml" and only /usr/myapp" exists, it will first create data, then 20060407 under that, and finally xml under that to complete the structure.
mkDir would just give you an error.
So if you pass it "/usr/myapp/data/20060407/xml" and only /usr/myapp" exists, it will first create data, then 20060407 under that, and finally xml under that to complete the structure.
mkDir would just give you an error.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
![]() |
Similar Threads
- Question about debugging .class file (Java)
- How it is possible tu use a class that is in a new vb file?? (ASP.NET)
- How to load binary content of a .class file? (Java)
Other Threads in the Java Forum
- Previous Thread: Data validation within a multi-dimensional array
- Next Thread: who can help me with GUI??
| Thread Tools | Search this Thread |
-xlint android api applet application array arrays automation bi binary blackberry block bluetooth chat class classes client code compile compiler component database developmenthelp draw eclipse error event exception fractal freeze game gameprogramming givemetehcodez graphics gui html ide image input integer j2me j2seprojects java javac javaprojects jetbrains jni jpanel jtable julia learningresources lego linux list login loop loops mac map method methods mobile netbeans newbie notdisplaying number online oracle page print problem program programming project qt recursion scanner screen server set singleton size sms sort sql string swing system template textfields threads time title tree tutorial-sample update variablebinding windows working xor






