APS Excellence in Physics Education Award
November 2019

Education Prize Logo
Science SPORE Prize
November 2011

NSF Logo
The Open Source Physics Project is supported by NSF DUE-0442581.

Loading *.txt files post and replies

Return to the Loading *.txt files thread
Login to post to this thread

_readText(String filename)
Alberto Porras
5 Posts

Hello,

I'm using the predefined methods for loading a *.txt file to a program I'm developing with EjsS. The command I use is:

_readText("List1.txt");

With this, I thought I would be able to load the file List1.txt (which only contains a string of characters) into the aforementioned program, but it doesn't seem to work...
Is there something I misunderstood about this command?

On another note, is it possible to select by hand the file you want to load without specifying its filename in the command?

Thank you in advance,
Alberto


Replies to _readText(String filename)

Re: _readText(String filename) -
Francisco Esquembre
228 Posts

Alberto,

The Java methods for writing and reading work. But, please, make sure that the file is located where the method expect. Typically, the path of the file refers to the place where the jar is located.

See attached example. Save a file and notice where is the data.txt.

Paco

Attached File: ejs_src__WritingAndReadingASCII.zip



OSP Projects:
Open Source Physics - EJS Modeling
Tracker
Physlet Physics
Physlet Quantum Physics
STP Book