View Single Post
  #1   Spotlight this post!  
Unread 13-10-2012, 22:54
joelg236 joelg236 is offline
4334 Retired Mentor & Alumni
AKA: Joel Gallant
no team
Team Role: Mentor
 
Join Date: Dec 2011
Rookie Year: 2012
Location: Calgary
Posts: 733
joelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond repute
WPILIBJ java.io.File equivalent

What class in the WPILIBJ would provide similar functionality as the java.io.File class does in Java SE? I can't seem to find anything appropriate.

Also, how would I be able to read a .TXT file via ftp to the robot? Ideally I'd like to have a method that converts the contents of the file to a string. I have done this in SE with Scanner in Java SE, how would I do it with FileInputStream or something of the like?

Example of what I'd like to do in Java SE :

Code:
public static String getStringFromFile(File file) throws FileNotFoundException {
    if (!file.exists()) {
        throw new FileNotFoundException();
    }
    try {
        return new Scanner(file).useDelimiter("\\A").next().trim();
    } catch (java.util.NoSuchElementException e) {
        return "";
    }
}
__________________
All opinions are my own.
Reply With Quote