Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6357737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:13:33+00:00 2026-05-24T23:13:33+00:00

I download an image file from an FTP Server using FTPClient . My look

  • 0

I download an image file from an FTP Server using FTPClient. My look like this:

public class FtpDownloadDemo
{
 public static void main(String[] args)
 {
  FTPClient client = new FTPClient();
  FileOutputStream fos = null;

  try
  {
    client.connect("ftp.domain.com");
    client.login("user", "pass");

    //
    // The remote filename to be downloaded.
    //
    String filename = "side.jpg";
    fos = new FileOutputStream(filename);

    //
    // Download file from FTP server
    //
    client.retrieveFile("/" + filename, fos);
  }
  catch (IOException e)
  {
    e.printStackTrace();
  }
  finally
  {
    try
    {
      if (fos != null)
      {
        fos.close();
      }
      client.disconnect();
    }
    catch (IOException e)
    {
      e.printStackTrace();
    }
  }

 }
}

When the file is downloaded the output looks distorted as shown below;

enter image description here

Is there a way to check if all the bytes has been received else wait till all is received?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T23:13:34+00:00Added an answer on May 24, 2026 at 11:13 pm

    I strongly suspect that the real problem is that the transfer is done in ASCII, rather than binary, mode.

    Try calling client.setFileType(FTP.BINARY_FILE_TYPE); before initiating the transfer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

public class FtpDownloadDemo { public static void Connection(String filename) { FTPClient client = new
So far i wrote a code to download a file from ftp server then
My app downloads a small image file from a remote server and I am
I've download an image from the Internet and converted to a String (This is
I need to download an image from some URL to my server. However, my
I am trying to download the image from the url http://a3.twimg.com/profile_images/414797877/05052008321_bigger.jpg I am using
I am trying to write a code to download file from server. i am
I want to download a file from server to a local host. i have
Hail! I want to fetch image from NOT PUBLIC Google Site's page. I'm using
I'm loading an image file from a web server, and then saving it to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.