How to convert string to input stream in Bioclipse JavaScript editor?

I am trying to save a string in a file using javascript in a Bioclipse workbench using

ui.save( "filename", "my string" );

... but you get an error that ui.save only accepts the input stream as the second parameter. How can I convert a string to input in a JavaScript context in Bioclipse?

(Btw, I think Bioclipse uses the Rhino implementation of Javascript)

+5
source share
2 answers

In this situation, we must return to Java.

You are trying to call the ui.save method, which according to the man ui.savefollowing:

> man ui.save
---------------------------------------------
ui.save(String filePath, InputStream content)
---------------------------------------------
Save the content of the InputStream to the given path.

, InputStream. Rhino Java. , , ...

var stream = new java.io.ByteArrayInputStream(
                      new java.lang.String("Example String").getBytes("UTF-8") );

( , )

ui.save("/test/test.txt", stream);
+3

All Articles