• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem reading test file in Eclipse Luna  RSS feed

David Ellis Rogers
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using Eclipse Luna, release 2 (4.4.2); Java on a Mac Pro Notebook running OS X Yosemite, version 10.10.5.  I cannot read a simple text file.  The following code shows the problem.  I have unsuccessfully tried several solutions.

Charset cs = Charset.forName("US-ASCII");
Path p4 = Paths.get("Test456");
Path p4AbsPath = p4.toAbsolutePath();
System.out.println("ABSOLUTE PATH IS p4AbsPath: " + p4AbsPath);
above yields:
"ABSOLUTE PATH IS p4AbsPath:Users/davidellisrogers/Documents/workspace/PaniniIndexing/Test456
From the above we know that actual path is

However, in the Mac Finder I locate file Test456 (the only one by that name on my hard drive) at the following location:  Macintosh HD/Users/davidellisrogers/Documents/Test456
The workspace is Eclipse’s.  Are there symbolic links involved. (?)
How do I access a simple file in this environment?  Is there some environment variable that must be set in Eclipse?

Note:  I am testing with a simple .txt file, but eventually would like to readAllLines in a .pdf of .docx file.

I am absolutely baffled by this. And would greatly appreciate some assist.
Liutauras Vilda
Posts: 4917
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, welcome to the Ranch David,

Path.get() isn't a search function, so you cannot locate folder just like that regardless where it is on your local drive. In your case you got the default absolute path of "Test456" which is referring to your eclipse project (that is intended), but this is not what you want, unless your simple.txt is added to your eclipse project subfolder "Test456".

Why don't you just explicitly specify a full path where the actual file is?
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!