For instance, running the code from the command line like in the example above, the working directory is the bin. Similarly, if this was your project structure ProjectRoot\src\word.txt, then the path "src/word.txt" would be valid.įor one, the working directory could always change. So when the file is in the ProjectRoot, then using just the file name as the relative path is valid, because it is at the root of the working directory. With your IDE (at least all the ones I've worked with), the working directory is the ProjectRoot. The working directory is C:\EclipseWorkspace\ProjectRoot\bin. The working directory, can be described as this:Ĭ:\EclipseWorkspace\ProjectRoot\bin > java 1 When you use File or any of the other FileXxx variants, you are looking for a file on the file system relative to the "working directory". Put the word.txt directly as a child of the project root folder and a peer of src Project_Rootĭisclaimer: I'd like to explain why this works for this particular case and why it may not work for others.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |