Right now, I'm simply attempting to read the contents of a file stored in the same directory as my Java classes, and access the length. However, whenever the correct file name is passed to create a new File
object, its length comes back as being zero. I assume that this is because the file cannot be found for some reason.
My file structure is as follows:
-src
--hw1 (package)
---TextSwap.java
---letters.txt
I try to create a file object with
File file = new File(filename);
, where filename
is equal to letters.txt
.