简体   繁体   中英

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.

相对于项目,相对于项目的位置在哪里

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM