Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   file i/o in java (http://www.chiefdelphi.com/forums/showthread.php?t=85012)

amk 06-04-2010 14:09

file i/o in java
 
Does anyone have example code for how to open and write to a text file on the cRIO? We would like to write out information while the robot for debugging purposes, then ftp the file to a laptop for viewing. Any help is appreciated.

Robototes2412 06-04-2010 17:49

Re: file i/o in java
 
if i remember right, they removed that feature from java, i suggest writing a class in c++ then use JNA to call it

rrossbach 06-04-2010 20:37

Re: file i/o in java
 
Quote:

Originally Posted by amk (Post 949248)
Does anyone have example code for how to open and write to a text file on the cRIO? We would like to write out information while the robot for debugging purposes, then ftp the file to a laptop for viewing. Any help is appreciated.

Take a look at my post here for an example.

- Ron
Team #2607 controls mentor

derekwhite 07-04-2010 23:20

Re: file i/o in java
 
I'll second Ron's approach.

As an FYI, once you have an OutputStream to the file, you can wrap it with a PrintStream and use the typical print methods on the file.


Quote:

PrintStream out;
DataOutputStream theFile;
FileConnection fc;

try {
fc = (FileConnection)Connector.open("file:///output.txt", Connector.WRITE);
fc.create();
theFile = fc.openDataOutputStream();
out = new PrintStream(theFile);
} catch (Exception e) {
...
}

spartango 08-04-2010 02:49

Re: file i/o in java
 
See
http://code.google.com/p/grtframewor...GRTFileIO.java

You can use that file verbatim or copy it and use its innards in your code.

Robototes2412 08-04-2010 13:20

Re: file i/o in java
 
THanks, is there anyway to append to a file?


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

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