Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   WPILIBJ java.io.File equivalent (http://www.chiefdelphi.com/forums/showthread.php?t=109135)

joelg236 13-10-2012 22:54

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 "";
    }
}


krieck 14-10-2012 23:30

Re: WPILIBJ java.io.File equivalent
 
You can read and write files on the cRIO using the com.sun.squawk.microedition.io.FileConnection class. FileConnections are opened using the javax.microedition.io.Connector class.

And yes, you should be able to read and write text files through FTP.

rrossbach 15-10-2012 15:12

Re: WPILIBJ java.io.File equivalent
 
Take a look at these threads for some pointers:

http://www.chiefdelphi.com/forums/sh...217#post924217

http://www.chiefdelphi.com/forums/sh...440#post949440

- Ron
Team #2607 controls mentor


All times are GMT -5. The time now is 09:15.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi