aspose file tools*
The moose likes Java in General and the fly likes Retrieval of values from a file in a remote server using JSch library Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Retrieval of values from a file in a remote server using JSch library" Watch "Retrieval of values from a file in a remote server using JSch library" New topic
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: 19541
    
  16

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 - OCEEJBD 6
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: 19541
    
  16

You're welcome.
 
Don't get me started about those stupid light bulbs.
 
subject: Retrieval of values from a file in a remote server using JSch library
 
Similar Threads
Java remote paths
Connecting two linux machines using smb
File Upload through JSP
File Upload Error - Using JSCH/SFTP
jsch file copy from Linux to Windows