View Single Post
  #13   Spotlight this post!  
Unread 13-04-2015, 19:15
ShortCircuit908's Avatar
ShortCircuit908 ShortCircuit908 is offline
King of Hacky Fixes
AKA: Caleb Milligan
FRC #4450 (Olympia Robotics Federation)
Team Role: Programmer
 
Join Date: Mar 2015
Rookie Year: 2014
Location: Olympia, WA
Posts: 7
ShortCircuit908 is an unknown quantity at this point
Re: Text files on the roborio?

Quote:
Originally Posted by GeeTwo View Post
Code:
.
.
        Map<String, String> env = System.getenv();
.
.
        f = new File(env.get("HOME") + "/Output.txt");
.
.
Another option is simply defining a non-absolute path, which would make the file relative to the working directory (where the jar file is located).
Code:
File file = new File("Output.txt");
Other than that, referring to solving "File or directory not found," you also have to create the directory that the desired file resides in, in addition to the actual file.

Code:
File file = new File("new_directory/Output.txt");
file.mkdirs();
file.createNewFile();
This would ensure that the directory "new_directory" is created before "Output.txt" is created.
Reply With Quote