Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   File Handling (http://www.chiefdelphi.com/forums/showthread.php?t=83044)

Patrick Chiang 18-02-2010 21:07

File Handling
 
How would I read/write from a file in Java? It seems that FRC has omitted the Scanner and the FileOutputStream classes, the only ways I know how to do file io.

Thanks in advance

rrossbach 19-02-2010 20:47

Re: File Handling
 
Look at the javadocs for the following classes:

com.sun.squawk.microedition.io.FileConnection
javax.microedition.io.Connector
java.io.DataOutputStream
java.io.DataInputStream

For example, to create an output file on the cRIO:

DataOutputStream theFile;
FileConnection fc;

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

You can then use the writeXXX() methods in DataOutputStream to write to the file. Be sure to flush() also.

- Ron
Team #2607 controls mentor


All times are GMT -5. The time now is 03:28.

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