Lidar-Lite Laser Module icon Lidar-Lite Laser Module — Laser Lidar-Lite ARC control reads distance, velocity and signal strength (0-40m+) via EZ-B v4 i2c, setting EZ-Script vars for robotics Try it →
Asked
Resolved Resolved by DJ Sures!
1 Participant
Reading and Writing Files in Java

Reading And Writing Files In Java

I am not a Java expert.  Can someone post an example of how to open/write and open/read a file on my local computer using the ARC Java Script editor?

Thank you very much.



Related Hardware (view all EZB hardware)
EZ-B V4 by EZ-Robot
EZ-B v4 with Synthiam ARCx controls servos, sensors, camera and audio over Wi-Fi or USB serial, no firmware needed.
Wi-Fi / USB
Servos 24
Camera
Audio
UART 3
I2C
ADC 8
Digital 24

ARC Pro

Upgrade to ARC Pro

Become a Synthiam ARC Pro subscriber to unleash the power of easy and powerful robot programming

Author Avatar
PRO
Synthiam
LinkedIn Thingiverse Twitter YouTube GitHub
#1   — Edited

I believe you mean JavaScript. Synthiam does not support anything Java related. There's a big difference (not only in the spelling) of Java and JavaScript:)

Use the File class to write files. Type File and hit . and all of the related stuff will appear.

User-inserted image


var filename = "C:\\temp\\testfile.txt";

File.appendString(filename, "Some data to write");

var x = File.readLine(filename);

File.readClose(filename);

print(x);
Author Avatar
PRO
USA
#2  

Thanks.  No where could if find i needed a double \ in the file path.

Author Avatar
PRO
Synthiam
LinkedIn Thingiverse Twitter YouTube GitHub
#3  

In programming, a \n in a string means new line. or \t means tab. There's a whole list of "escape characters" for strings.

Author Avatar
PRO
Synthiam
LinkedIn Thingiverse Twitter YouTube GitHub
#4  

I found this for ya on google 

JavaScript String Escape / Unescape

Escapes or unescapes a JavaScript string removing traces of offending characters that could prevent interpretation.

The following characters are reserved in JavaScript and must be properly escaped to be used in strings:

Horizontal Tab is replaced with \t Vertical Tab is replaced with \v Nul char is replaced with \0 Backspace is replaced with \b Form feed is replaced with \f Newline is replaced with \n Carriage return is replaced with \r Single quote is replaced with ' Double quote is replaced with " Backslash is replaced with \

Author Avatar
PRO
USA
#5  

Thank you.  Learning as i go.