user3339242
user3339242

Reputation: 641

How to read in txt file outside of project folder with Java Netbeans

I want to read in/access a txt file outside of my main project folder in Netbeans. For example,

Project Folder
    ->src
    ->bin
Txt File

My project folder and txt file are on the same level(in the same folder).

The project is located in Documents/ComputerPrograms/489/ProjectName The txt file is located in Documents/ComputerPrograms/489/txtFile.txt

Usually I would use

./txtfile.txt

if the txt file was located within the Project Folder. Also, I want to do this using a relative path not an absolute path.

Upvotes: 0

Views: 4537

Answers (1)

PotatoPhil
PotatoPhil

Reputation: 166

Where is it, relative to relative to the project, to find it relative it would be

BufferedReader reader = new BufferedReader(new File("hierarchy relative to project folder, ex; "bin/com/me/proj/hello"));

Upvotes: 3

Related Questions