function readFile() {
var fname = "D:/tmp/test.txt";
try {
var fin = new java.io.FileInputStream(fname);
var ins = new java.io.DataInputStream(fin);
var fcontent = "";
while(ins.available() !=0) {
console.debug(ins.readLine()) //firebug console
}
}catch(ex) {
console.debug(ex);
}finally {
ins.close();
}
}
Not sure, what do you mean? You can use java via xpcom only. But not only java, you can use C++, python, javascript in
the same way as java. What's difference?
I'm a little confused, sorry. :-)
Are you saying that with a standard Firefox 2.0 I can create a python object in
the same way as java?
I can write to a local file using javascript in this way?
var out = new java.io.BufferedWriter(new java.io.FileWriter("test.txt"));
out.write("Hello World");
What surprised me is that I can use every j2se classes out-of-the-box without
any security restriction (in chrome).
I think that there are some cases where is easier using java than an XPCOM
component.
That's not true. You can use Java directly too, like his code sample
showed... Using Java via XPCOM doesn't work in a standard Firefox
(neither does Python).
>> Not sure, what do you mean? You can use java via xpcom only. But not
>> only java, you can use C++, python, javascript in the same way as java.
>> What's difference?
> I'm a little confused, sorry. :-)
>
> Are you saying that with a standard Firefox 2.0 I can create a python object in
> the same way as java?
I feel I don't know what is the "way as java"... ;)
But ActiveState Komodo is built on mozilla platform with python.
> I can write to a local file using javascript in this way?
>
> var out = new java.io.BufferedWriter(new java.io.FileWriter("test.txt"));
> out.write("Hello World");
Yes, but JavaScript doesn't contain io stuff. So you have to use other xpcom-components, like
"@mozilla.org/network/file-output-stream;1"
> What surprised me is that I can use every j2se classes out-of-the-box without
> any security restriction (in chrome).
Of course, mozilla doesn't have any access to JVM internals.
> I think that there are some cases where is easier using java than an XPCOM
> component.
Yeah... maybe... but not all cases definitely. Just make dependencies on the 20-25 mb JRE only just for writing a
file... moreover you can make it with mozilla-native components.