[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [geclipse-dev] Open InputStream
|
POD69@xxxxxxx pisze:
Hi all
I thought URI("gsiftp://aliserv6.ct.infn.it:2811/dpm/ct.infn.it/home/geclipsetutor/getutor.t01"); should be enough to point at the file to fetch.
But it still doesnt work - The file is found but the content isnt printed out?
IFileStore fs = EFS.getStore( uri );
for (IFileStore store : fs.childStores(EFS.NONE,null)) {
if ( store.getName().equals("getutor.t01") ) {
file1 = store;
System.out.println(file1.getName() );
break;
}
}
BufferedInputStream stream = new BufferedInputStream(file1.openInputStream(EFS.NONE, null));
while(stream.available() != 0)
System.out.print((char)stream.read());
I get no exceptions in the eclipse console - In the eclipse log is
I shouldn't receive corporate mail at home... It's unhealthy ;-)
These exceptions are harmless, I think so, or at least they are not
related to your code nor glite stuff.
The problem I would look closer at is the method stream#available().
Because opening an input stream may take a while (to wait for server to
start sending data), you may end up with 0 returned.
The available() method is, as far as I know, designed to check if there
is available data to perform a non-blocking waiting.
// from java doc
public int available()
throws IOException
Returns the number of bytes that can be read (or skipped over) from
this input stream without blocking by the next caller of a method for
this input stream. The next caller might be the same thread or or
another thread.
// end of java doc
I would recommend to use something like this to read data:
do {
b=(byte) stream.read();
System.out.print((char)b);
} while(b!=-1);
stream.close();
Of course this is just an example,
more efficient way would be to use some buffer (esp. for writing, since
input stream is already buffered).
!ENTRY org.eclipse.update.configurator 2008-05-29 18:43:50.723
!MESSAGE Unable to find feature.xml in directory: /home/pod/eclipsetest/eclipse/features/eu.geclipse.aws_1.0.0.N20080529-0500.jar
!ENTRY org.eclipse.update.configurator 2008-05-29 18:43:50.724
!MESSAGE Unable to find feature.xml in directory: /home/pod/eclipsetest/eclipse/features/eu.geclipse_1.0.0.N20080529-0500.jar
!ENTRY org.eclipse.update.configurator 2008-05-29 18:43:50.765
!MESSAGE Unable to find feature.xml in directory: /home/pod/features/eu.geclipse_1.0.0.N20080516-0600.jar
!ENTRY org.eclipse.update.configurator 2008-05-29 18:43:50.765
!MESSAGE Unable to find feature.xml in directory: /home/pod/features/eu.geclipse.aws_1.0.0.N20080516-0600.jar
I use the latest NIghtlyBuilds
thx pod
-------- Original-Nachricht --------
Datum: Thu, 29 May 2008 18:07:41 +0200
Von: Mateusz Pabis\' <uranium@xxxxxxxxxxxxx>
An: Developer mailing list <geclipse-dev@xxxxxxxxxxx>
Betreff: Re: [geclipse-dev] Open InputStream
POD69@xxxxxxx pisze:
Hi all
I dont know whats wrong with that code?
That should open a Stream on the getutor.t01 file and print out its
content? Whats wrong with that? Am I wrong.
URI uri = new
URI("gsiftp://aliserv6.ct.infn.it:2811/dpm/ct.infn.it/home/geclipsetutor/getutor.t01");
IFileStore fs = EFS.getStore( uri );
BufferedInputStream stream = new
BufferedInputStream(fs.openInputStream(EFS.NONE, null));
while(stream.available() != 0)
System.out.print((char)stream.read());
As I replied to Romain (in one post nearby):
Also I didn't figure out how to perform fetchInfo for a single file,
without listing whole directory. Hence, if you would like to download a
single file, you should perform this cumbersome usecase (in pseudocode):
fs = getFileStore (new
URI("gsiftp://server:2811/path/to/the/parent/directory/") )
find in fs.childStores your desired file, call it fsfile
fsfile.get(Input|Output)Stream();
So, in your case it would look like this:
URI uri = new
URI("gsiftp://aliserv6.ct.infn.it:2811/dpm/ct.infn.it/home/geclipsetutor/");
IFileStore file;
IFileStore fs = EFS.getStore( uri );
for (IFileStore store : fs.childStores() ) {
if ( store.getName().equals("getutor.t01") ) {
file = store;
break;
}
}
BufferedInputStream stream = new
BufferedInputStream(file.openInputStream(EFS.NONE, null));
while(stream.available() != 0)
System.out.print((char)stream.read());
and that
URI uri = new
URI("gsiftp://aliserv6.ct.infn.it:2811/dpm/ct.infn.it/home/geclipsetutor/foofo/");
IFileStore fs = EFS.getStore( uri );
Please try to invoke #childStores() or childNames() here
IFileStore homeDir =
fileSystem.getStore(URI.create("/home/pod/files/"));
fs.copy(homeDir, EFS.OVERWRITE, null);
should copy all files and dirs recursively - but doesnt work ?
the only thing that works is fs.mkdir() I can create a dir.
So what to do?
hope this helps.
I'll be here for next 1hr in case you need more help :-)
--
Mateusz Pabis