Andrew Meng wrote:
Hello,
I am working a JavaSpace applicaton in which one of the task needs to open
> and read a text files in its execute() method. It seems that there are two
options here:
1)Reading the text file to a StringReader(which is a member variable in the
task object)
2)Puting the text file into the codebase root directory for the normal class or
> jar files but I could not figure out how to do it for a normal text file.
Can anyone share what you would do in this case?
If the file is part of the work item that execute() will process, then put a URL
(String value that you can construct a URL object with in execute()). Then
you can change where you put it and how it is accessed over time by using a
different URL, changing the protocol (jar:, http:, ftp:, or your own custom
protocol handler that you inject into the JVM runtime with
-Djava.protocol.handler.pkgs etc).
Definitely try not to send the data in the Entry so that you don't end up
slinging data all over the network until you need it.
Gregg Wonderly