Download the file of the sftp server: 0 bytes. Why?

I have a function to download a file from the server international:

' Public Sub downloadFileListener (FacesContext facesContext, OutputStream outputStream) throws IOException,.

JSchException,

{SftpException}

AdfFacesContext context = AdfFacesContext.getCurrentInstance ();

Card vScope = context.getViewScope ();

FacesCtrlHierNodeBinding viewScopeRow = (FacesCtrlHierNodeBinding) vScope.get ("qcDocSelectedRow");

System.out.println ("selected line:" + viewScopeRow);

If (viewScopeRow! = null & & viewScopeRow.getAttribute ("DocAddr")! = null) {}

String pathBind = viewScopeRow.getAttribute("DocName").toString ();

String addr = viewScopeRow.getAttribute("DocAddr").toString ();

System.out.println ("addr:" + addr);

Filed file = new File (addr);

FileInputStream fis;

Byte [] b.

try {}

String SFTPHOST = "10.197.50.234";

int SFTPPORT = 22;

String SFTPUSER = "wrrw;

String SFTPPASS = "rwwrwr";

String SFTPWORKINGDIR = "/ var/www/html/QC/QC01000243/100039287 /";

A session = null;

Channel = null;

ChannelSftp channelSftp = null;

System.out.println ("AGAIN!");

JSch jsch = new JSch();

session = jsch.getSession (SFTPUSER, SFTPHOST, SFTPPORT);

session.setPassword (SFTPPASS);

java.util.Properties config = new java.util.Properties ();

config.put ("StrictHostKeyChecking", "no");

session.setConfig (config);

session. Connect();

Channel = session.openChannel("sftp");

Channel.Connect ();

System.out.println ("conectou");

channelSftp = channel (ChannelSftp);

System.out.println ("SFTPWORKINGDIR:" + SFTPWORKINGDIR);

channelSftp.cd (SFTPWORKINGDIR);

System.out.println ("estas aqui!");

ubyte [] buffer = new byte [1024];

FIS = new FileInputStream (SFTPWORKINGDIR);

Buffer fis = new buffer (channelSftp.get ("macaco.gif"));

int n;

While ((n = fis.available ()) > 0) {}

System.out.println ("here is");

b = new ubyte [n];

result int = fis.read (b);

outputStream.write (b, 0, b.length);

If (result == - 1).

break;

}

} catch (IOException e) {}

e.printStackTrace ();

System.out.println ("exception:" + try ());

}

outputStream.flush ();

}

}

The file exist in the server. However, when I try to get the file have 0 bytes.

What's wrong?

Pls help me, my version jdev is 11.2.4.0

Hello

Just check your code again. Here are a few references. Just hardcode the path and try to debug the java method.

SFTP for Java examples

JSch - Java secure channel - examples

Thank you
Amey

Tags: Java

Similar Questions

  • What would cause the "from address" info (FA). some emails, downloading the pop3 server, will be replaced by an 'f' 'common '?

    I get multiple research work emails (E/JS) and ecommerce. Some of them have a "Correct".
    'St. Michael Job Assistance Ministry - JAM' FA (SMJAM-JAM).

    For some reason, however, some of the emails from other sources, downloading the verizon pop3, E/JS server are indicated (wrongly) as having the FA SMJAM-JAM above. This situation prevents my email filters to plug these emails to their appropriate mail folder.

    Also, when the steps in order to transmit emails showing incorrect information of FA SMJAM-JAM, the e-mail is no longer present incorrect information of FA SMJAM-JAM but shows rather the correct information of FA that had been specified on the verizon pop3 server.

    address ROM"(FA) in some emails, when downloading from the pop3 server, is replaced by a 'common' 'FA '. [email protected]

    What would cause the "from address" info (FA). some emails, downloading the pop3 server, will be replaced by an 'f' 'common '?

    Hello

    If I understand your problem, I think it may have to do with the addresses stored in your address book. Thunderbird can display the name of your address book instead of the name of the post office, where corresponds to the e-mail address.

    Check your address books to see if you have a bad entry for mail addresses get listed wrong.

    Also check under Tools-> Options-> advanced-> reading & display if you have checked the option to see show it only the names of the people in my address book. If you uncheck this option, the name and the address must be...

  • I get a message that I don't have the latest version of Firefox. I just updated and downloaded the Beta Version 11. Why do I get this message?

    I get a message that I don't have the latest version of Firefox. I just updated and downloaded the Beta Version 11. Why do I get this message?

    The current beta version is 12 of Firefox, but if you're not a tester experienced, so it is best to stay with the current version of Firefox and uninstall the beta version.

    You can find the latest version of Firefox in all languages and for all systems operating here:

  • I downloaded the Windows Server 2008 R2 SP1 180 trial version. How can I get the key?

    Hi, I want to install the Windows Server 2008 R2 SP1 180 trial version. I downloaded from:
    http://TechNet.Microsoft.com/en-us/evalcenter/ee175713.aspx

    but I don't have the key. How to register and get the key.

    Another question:
    Is it possible to install Windows Server 2008 R2 SP1 180 trial version as a virtual server on my Windows 7 Home premium version? If Yes, how can I do it, because it seems Windows 7 Home premium version do not support Windows Server 2008 R2 with SP1 as machine visualization.

    Thank you.

    Assessment of any version of the software Windows Server 2008 R2 SP1 does not require entering a product key.  Thus, no product key is issued.

    Q. "is it possible to install the Windows Server 2008 R2 with SP1 180 day trial version as a virtual server on my Windows 7 Home premium version?

    A. no, it is not supported.

  • Multiple Upload of files via a SFTP server

    Hi team,

    I have a requirement where I need to create a screen allowing the user to download pdf files and there is a button to download next to the upload of a file that will be activated once a file is downloaded; at the click of button transfer we will show him in a set of tables containing documents downloaded but not inserted in the db for this I create a line in vo with details of file as file name and content type.


    I am able to do the same a click on Download button and the same server sftp, checked the size of the file is but I don't want to download one by one because there are chances that the user can roll back everything or it can close the browser or anyone, even that I have to establish a connection whenever a file is downloaded.


    What I did is I created a class with inputstream and string variables.

    Sample

    / public class MultipleFilesHolder implements Serializable {}

    public MultipleFilesHolder() {}

    Super();

    }

    private InputStream inputStream;

    private String fileName;

    private static final long serialVersionUID = 98599739738L;

    with the getter and setter

    Whenever I press a button download I create an object in MultipleFilesHolder for details.

    Now on the validate button, I call my sftp and upload all the files one by one.

    Problem is when I check in my server files are getting created with 0 bytes.

    Please share your comments/opinions so it is best to do this or have I missed somewhere.

    I don't want to use temporary location for files for interim use and transfer to the call of validation .


    My version of Jdev is 11.1.2.4.0.

    Thank you.

    Team,

    I am able to achieve this functionality so closing forum. Will share my solution as soon as possible.

  • Cannot open any website because the proxy server refuses connections, why?

    Firefox is open but cannot open any website. The message said: "the proxy server refuses connections" & "Firefox is configured to use a proxy server refusing connections." I installed the 8.0.1 version again. But he had the same message, once again!

    Have you tried it on another browser/computer connected to the same network. If an error of the same type was on Chrome or IE, contact your ISP

  • Select the remote server to download files.

    With the help of CS5.5 I am unable to put files on my test server, except if the remote server is selected. He said: "before using this feature, you must set up a remote server. You want to book one now? ".

    If I check the remote server, I am able to upload files to the test server, also download the remote server that is BAD, I'm just testing and redesigning the site.

    I found another thread saying to remove the site, I did; Nothing helps.

    If I do not select a remote server I'm unable to download and to remodel the site.

    How do you have on this?

    Managed to fix it I made my server under servers model > advanced > server model has been configured for PHP MySQL.

  • Open / download the file from the server db

    Hello guys!

    I have spent ages to find a way to open respectively to download a file from my db server.
    I use a stored procedure to write an xml file in a directory with an alias "DIR_EXCEL_EXPORT". (This directory is created in the database to reference the folder on the db server. The folder is/tmp).

    Can you please give me an example how to download the file created automatically once the file is created or at least how to open it manually using a button in the apex?

    I appreciate your efforts and your ideas on this topic.

    Best regards

    SEB

    Hello

    Make sure that your button attributes
    Target "Page of this Application.
    Page & APP_PAGE_ID.
    Defined for example application DOWNLOAD_XML

    Then check that your APA process is conditional on demand DOWNLOAD_XML

    Also, make sure that DAD user have read privilege to the directory that you are using

    Kind regards
    Jari

  • Create the SFTP connection

    When you configure an SFTP connection, I get my credentials, it connects and allows me to browse the server, but when I then click on the screen ' on the SFTP server, this folder contains your website? I get the error failed to check the connection information

    Why he would let me go if she can not connect? It must be connected... so I don't know how to take this step.

    Any information would be appreciated

    Thank you

    OK, I got it figured out.

    Contribute must match all that you select the site that you are connecting with and your Web site folder.

    It must detect certain things and not tell, because if they do not match, it won't let you go further.

    I am trying to connect to a Drupal site.  Then, when I selected the folder of a deep subdirectory in drupal... He didn't like it.

    Select the root of the installation of drupal (where the index.php) resides, it worked.

    This question is closed. It works fine using SFTP over an SSH connection.

    Thank you graffitti that responded to the questionnaire.

  • How to download the eng version?

    How to download the eng version?

    Why can't install chi (SP)?

    Open the creative application of cloud, in preferences, you will find an option to change the language of the apps.

    You will need to re - install.

    There is a faster way but cannot show you that I am not at my editing machine.

  • downloadable pdf file

    Hello

    I'm trying to make a downloadable pdf file from my ftp server.

    the best way to do is to download the file on the ftp server, but then I don't know how to link

    or what link I will give

    any help?

    Catalyst allows you to create a click on > the interaction of the url. This won't work for a http link, but you can change your project in the generator to make the link to load via ftp.

    -Bear

  • where can I download a free trial of vCenter Server 5?

    Hi all

    Any idea where I can download a free trial of vCenter Server 5?

    Please notify

    Thank you!

    After registering, click on the tab 'License & Download' and develop 'download the management server '.

    André

  • Firefox will not play SermonConnect mp3 files that have been uploaded to Amazon S3 server using S3 Organizer after 2014 7. Already downloaded the files OK.

    Files uploaded to the Amazon S3 server are accessible via our Web site at littlecountrychurch.org. All multimedia files downloaded before January 7, 2014, be played properly on our media page. Files uploaded after January 7 refuses to play on the Firefox browser. To add to the confusion, other browsers Chrome, Safari, Internet Explorer on Windows and Mac-play these files correctly. In addition, an older version of Firefox on an XP laptop plays files correctly. We even ran a test by downloading a working of the S3 server, re-uploaded the file file and Firefox would not read the freshly downloaded file, but he continued to play the same file previously downloaded without problem.

    The problem is the content-type header sent to S3. The old MP3s are designated "audio/mpeg", which is perfect. Newcomers are designated "application/download", which does not work in Firefox native HTML5 audio player. (The inset on the screenshots is pasted from a screenshot of the Fiddler proxy).

    On a normal web server, all .mp3 files usually served in the same folder have the same content type. Something seems different about Amazon storage, perhaps based on a difference in their environment "backstage."

  • Content file download failed. Reason: The RPC server is unavailable.

    Hello

    Please help, I have the following error with my WSUS. The clocks are so successful.

    According to the survey, it is said "updated the files needed: 2589 ' 'downloaded 0.0 MB of 30 years, MB 196,09.

    MT event logs show ID 364

    Content file download failed. Reason: The RPC server is unavailable. (Exception from HRESULT: 0x800706BA) Source file: /msdownload/update/v3-19990518/cabpool/windowsdesktopsearch-kb926356-v2-x86-nld_72b01991a8ebadf72d2512e19234943920ee4104.exe Destination file: c:\WSUS\WsusContent\04\72B01991A8EBADF72D2512E19234943920EE4104.exe

    I opened the firewall to allow full access to the net to the WSUS server, so it does not use a proxy.

    Please for any assistance you can offer.

    Did you run the Bits? Rob - bicycle - Mark Twain said it is good.

  • Ask for instructions to writing files music .mp3 download the server applications.

    Hello everyone.

    I need instructions on how to write applications for download music files .mp3 from the server and saved in the device memory. I would like to know which class should I use?

    Thank you

    MAZ

    A code example in this article which may help.

    http://supportforums.BlackBerry.com/T5/Java-development/download-large-files-using-the-BlackBerry-mo...

Maybe you are looking for