| Author |
Retrieval of values from a file in a remote server using JSch library
|
Shikha Upadhyaya
Ranch Hand
Joined: Aug 17, 2011
Posts: 70
|
|
Hi,
I tried the code in this website to retrieve a file from remote server to my local system. It is working fine. But is there any way to directly read the values from the file without actually copying the file to the local system? How do I do it?
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19232
|
|
You can't read anything from the file without copying it to your local system. That's also happening when you view any web page on the Internet; you download it first before your browser displays it.
That doesn't mean that you need to store it in a file. Instead of using a FileOutputStream you can use a ByteArrayOutputStream, then call its toByteArray() method to get the remote file contents in a byte[].
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Shikha Upadhyaya
Ranch Hand
Joined: Aug 17, 2011
Posts: 70
|
|
Rob Spoor wrote:You can't read anything from the file without copying it to your local system. That's also happening when you view any web page on the Internet; you download it first before your browser displays it.
That doesn't mean that you need to store it in a file. Instead of using a FileOutputStream you can use a ByteArrayOutputStream, then call its toByteArray() method to get the remote file contents in a byte[].
Oh ok. I will try this. Thanks
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19232
|
|
|
You're welcome.
|
 |
 |
|
|
subject: Retrieval of values from a file in a remote server using JSch library
|
|
|