Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Retrieval of values from a file in a remote server using JSch library

 
Shikha Upadhyaya
Ranch Hand
Posts: 70
Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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[].
 
Shikha Upadhyaya
Ranch Hand
Posts: 70
Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic