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

  • SEARCH
  • Home
  • 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 8793505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:07:51+00:00 2026-06-13T23:07:51+00:00

This code is working now. LogCat only for lead back problems from other ppl

  • 0

This code is working now. LogCat only for lead back problems from other ppl

How can I download a file from my ftp server without beeing damaged (the downloaded file)?
I can download the file but it has 0 Bytes….

But all the same .txt, .png, .exe, .apk files are everytime damaged / unreadable (0 Bytes) on my phone.
For example with a file on my ftp server called init.txt (it contains following text in it : “testfileini!!”) its size is 13 Bytes on ftp and 0 Bytes on phone.

OnItemClickListener (for directly selecting a file from the ftp file list)

lv.setOnItemClickListener(new OnItemClickListener() {
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
              String file = (String) lv.getItemAtPosition(position);
              new DownloadFile().execute(file);   
          }

        });

AsyncTask Downloadfile (for downloading in background)

    private class DownloadFile extends AsyncTask<String, Integer, String> {
    @Override
    protected String doInBackground(String... filename) {
        try {
            System.out.println("Filename->: " + filename[0]);
            GetFileFTP("/subdomains/giveyourapps/httpdocs/apps/"+filename[0], Environment.getExternalStorageDirectory() + "/Download/", filename[0]);

        } finally {
            disconnectFTP();
        }
        return null;
    }
}

GetFileFTP

public void GetFileFTP(String srcFileSpec, String destpath, String destname) {
    FTPClient client = new FTPClient();
    Log.v("pathSpec: ", destpath); 

    try {
        client.connect("176.28.25.46");
        client.login("ftp031220", "hSigSf");

        client.enterLocalPassiveMode();
        client.setFileType(org.apache.commons.net.ftp.FTP.BINARY_FILE_TYPE);            

        InputStream input = client.retrieveFileStream(srcFileSpec);
        if(input != null) Log.v("GetFileFTP: ", "Input Stream Opened successfully");
        Log.v("Fileinputstream: ", srcFileSpec); 

        File output_file = new File(destpath + destname);
        Log.v("OUTPUTFILE: ", destpath + destname); 

        inputstreamcopy(input, output_file);

        disconnectFTP();

    }catch (IOException e) {
            Log.e("FTP", "Error Getting File");
            e.printStackTrace();
    }
 } 

copyInputStreamToFile

public static void inputstreamcopy(InputStream source,
        File destination){
    try {
        org.apache.commons.io.FileUtils.copyInputStreamToFile(source, destination);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

LogCat

11-07 15:09:08.675: D/GestureDetector(15746): [Surface Touch Event] mSweepDown False, mLRSDCnt : -1 mTouchCnt : 3 mFalseSizeCnt:0
11-07 15:09:08.905: I/System.out(15746): status :: 211-Status of 'ProFTPD'

11-07 15:09:08.905: I/System.out(15746):  Connected from 109.164.221.167 (109.164.221.167)

11-07 15:09:08.905: I/System.out(15746):  Logged in as ftp031220

11-07 15:09:08.905: I/System.out(15746):  TYPE: BINARY, STRUcture: File, Mode: Stream

11-07 15:09:08.905: I/System.out(15746):  No data connection

11-07 15:09:08.910: I/System.out(15746): 211 End of status

11-07 15:09:09.025: D/dalvikvm(15746): GC_CONCURRENT freed 93K, 10% free 12464K/13703K, paused 15ms+12ms, total 58ms
11-07 15:09:09.390: I/System.out(15746): Files->: 1Tap_Cleaner_Pro_v1.45.apk
11-07 15:09:09.390: I/System.out(15746): Files->: AppBrain_App_Market_v7.5.apk
11-07 15:09:09.395: I/System.out(15746): Files->: Apparatus_v1.0.4_ADFREE_ANDROiD-P2P.apk
11-07 15:09:09.395: I/System.out(15746): Files->: Atomic_Bomber_5.0.apk
11-07 15:09:09.395: I/System.out(15746): Files->: IMG_20120917_120935.jpg
11-07 15:09:09.395: I/System.out(15746): Files->: init.txt
11-07 15:09:09.395: I/System.out(15746): Files->: unnamed.png
11-07 15:09:09.500: E/SpannableStringBuilder(15746): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
11-07 15:09:09.500: E/SpannableStringBuilder(15746): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
11-07 15:09:13.805: D/GestureDetector(15746): [Surface Touch Event] mSweepDown False, mLRSDCnt : -1 mTouchCnt : 2 mFalseSizeCnt:0
11-07 15:09:13.880: I/System.out(15746): Filename->: init.txt
11-07 15:09:13.880: V/pathSpec:(15746): /storage/sdcard0/Download/
11-07 15:09:14.310: V/GetFileFTP:(15746): Input Stream Opened successfully
11-07 15:09:14.310: V/Fileinputstream:(15746): /subdomains/giveyourapps/httpdocs/apps/init.txt
11-07 15:09:14.310: V/OUTPUTFILE:(15746): /storage/sdcard0/Download/outputfile.txt
11-07 15:09:14.310: I/dalvikvm(15746): threadid=11: stack overflow on call to Lcom/mseiz/give/your/apps/MainSite;.copyInputStreamToFile:VLL
11-07 15:09:14.310: I/dalvikvm(15746):   method requires 8+20+8=36 bytes, fp is 0x5ec4b310 (16 left)
11-07 15:09:14.310: I/dalvikvm(15746):   expanding stack end (0x5ec4b300 to 0x5ec4b000)
11-07 15:09:14.315: I/dalvikvm(15746): Shrank stack (to 0x5ec4b300, curFrame is 0x5ec4eeb0)
11-07 15:09:14.315: W/dalvikvm(15746): threadid=11: thread exiting with uncaught exception (group=0x40d9f2a0)
11-07 15:09:14.375: D/dalvikvm(15746): GC_CONCURRENT freed 283K, 10% free 12654K/14023K, paused 14ms+11ms, total 47ms
11-07 15:09:14.405: D/dalvikvm(15746): GC_FOR_ALLOC freed 314K, 11% free 12682K/14215K, paused 10ms, total 10ms
11-07 15:09:14.405: E/AndroidRuntime(15746): FATAL EXCEPTION: AsyncTask #1
11-07 15:09:14.405: E/AndroidRuntime(15746): java.lang.RuntimeException: An error occured while executing doInBackground()
11-07 15:09:14.405: E/AndroidRuntime(15746):    at android.os.AsyncTask$3.done(AsyncTask.java:299)
11-07 15:09:14.405: E/AndroidRuntime(15746):    at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
11-07 15:09:14.405: E/AndroidRuntime(15746):    at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
11-07 15:09:14.405: E/AndroidRuntime(15746):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
11-07 15:09:14.405: E/AndroidRuntime(15746):    at java.util.concurrent.FutureTask.run(FutureTask.java:137)
11-07 15:09:14.405: E/AndroidRuntime(15746):    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
11-07 15:09:14.405: E/AndroidRuntime(15746):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
11-07 15:09:14.405: E/AndroidRuntime(15746):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
11-07 15:09:14.405: E/AndroidRuntime(15746):    at java.lang.Thread.run(Thread.java:856)
11-07 15:09:14.405: E/AndroidRuntime(15746): Caused by: java.lang.StackOverflowError
11-07 15:09:14.405: E/AndroidRuntime(15746):    at com.mseiz.give.your.apps.MainSite.copyInputStreamToFile(MainSite.java:119)
11-07 15:09:14.405: E/AndroidRuntime(15746):    at com.mseiz.give.your.apps.MainSite.copyInputStreamToFile(MainSite.java:119)
11-07 15:09:14.405: E/AndroidRuntime(15746):    at com.mseiz.give.your.apps.MainSite.copyInputStreamToFile(MainSite.java:119)
11-07 15:09:14.405: E/AndroidRuntime(15746):    at com.mseiz.give.your.apps.MainSite.copyInputStreamToFile(MainSite.java:119)
11-07 15:09:14.405: E/AndroidRuntime(15746):    at com.mseiz.give.your.apps.MainSite.copyInputStreamToFile(MainSite.java:119)
11-07 15:09:14.405: E/AndroidRuntime(15746):    at com.mseiz.give.your.apps.MainSite.copyInputStreamToFile(MainSite.java:119)
11-07 15:09:14.405: E/AndroidRuntime(15746):    at com.mseiz.give.your.apps.MainSite.copyInputStreamToFile(MainSite.java:119)
11-07 15:09:14.405: E/AndroidRuntime(15746):    at com.mseiz.give.your.apps.MainSite.copyInputStreamToFile(MainSite.java:119)
11-07 15:09:14.405: E/AndroidRuntime(15746):    at com.mseiz.give.your.apps.MainSite.copyInputStreamToFile(MainSite.java:119)
11-07 15:09:14.405: E/AndroidRuntime(15746):    at com.mseiz.give.your.apps.MainSite.copyInputStreamToFile(MainSite.java:119)
11-07 15:09:14.405: E/AndroidRuntime(15746):    at com.mseiz.give.your.apps.MainSite.copyInputStreamToFile(MainSite.java:119)
11-07 15:09:14.405: E/AndroidRuntime(15746):    at com.mseiz.give.your.apps.MainSite.copyInputStreamToFile(MainSite.java:119)
11-07 15:09:14.405: E/AndroidRuntime(15746):    at com.mseiz.give.your.apps.MainSite.copyInputStreamToFile(MainSite.java:119)
11-07 15:09:14.405: E/AndroidRuntime(15746):    at com.mseiz.give.your.apps.MainSite.copyInputStreamToFile(MainSite.java:119)
11-07 15:09:14.405: E/AndroidRuntime(15746):    at com.mseiz.give.your.apps.MainSite.copyInputStreamToFile(MainSite.java:119)
11-07 15:09:14.405: E/AndroidRuntime(15746):    at com.mseiz.give.your.apps.MainSite.copyInputStreamToFile(MainSite.java:119)
11-07 15:09:14.405: E/AndroidRuntime(15746):    at com.mseiz.give.your.apps.MainSite.copyInputStreamToFile(MainSite.java:119)
11-07 15:09:14.405: E/AndroidRuntime(15746):    at com.mseiz.give.your.apps.MainSite.copyInputStreamToFile(MainSite.java:119)
11-07 15:09:14.405: E/AndroidRuntime(15746):    at com.mseiz.give.your.apps.MainSite.copyInputStreamToFile(MainSite.java:119)
11-07 15:09:14.405: E/AndroidRuntime(15746):    at com.mseiz.give.your.apps.MainSite.copyInputStreamToFile(MainSite.java:119)
11-07 15:09:14.405: E/AndroidRuntime(15746):    at com.mseiz.give.your.apps.MainSite.copyInputStreamToFile(MainSite.java:119)
11-07 15:09:14.405: E/AndroidRuntime(15746):    at com.mseiz.give.your.apps.MainSite.copyInputStreamToFile(MainSite.java:119)
11-07 15:09:14.405: E/AndroidRuntime(15746):    at com.mseiz.give.your.apps.MainSite.copyInputStreamToFile(MainSite.java:119)
11-07 15:09:14.405: E/AndroidRuntime(15746):    at com.mseiz.give.your.apps.MainSite.copyInputStreamToFile(MainSite.java:119)
11-07 15:09:14.405: E/AndroidRuntime(15746):    at com.mseiz.give.your.apps.MainSite.copyInputStreamToFile(MainSite.java:119)
11-07 15:09:14.405: E/AndroidRuntime(15746):    at com.mseiz.give.your.apps.MainSite.copyInputStreamToFile(MainSite.java:119)
11-07 15:09:14.405: E/AndroidRuntime(15746):    at com.mseiz.give.your.apps.MainSite.copyInputStreamToFile(MainSite.java:119)
11-07 15:09:14.405: E/AndroidRuntime(15746):    at com.mseiz.give.your.apps.MainSite.copyInputStreamToFile(MainSite.java:119)
11-07 15:09:14.405: E/AndroidRuntime(15746):    at com.mseiz.give.your.apps.MainSite.copyInputStreamToFile(MainSite.java:119)
11-07 15:09:14.405: E/AndroidRuntime(15746):    at com.mseiz.give.your.apps.MainSite.copyInputStreamToFile(MainSite.java:119)
11-07 15:09:14.405: E/AndroidRuntime(15746):    at com.mseiz.give.your.apps.MainSite.copyInputStreamToFile(MainSite.java:119)
11-07 15:09:14.405: E/AndroidRuntime(15746):    at com.mseiz.give.your.apps.MainSite.copyInputStreamToFile(MainSite.java:119)
11-07 15:09:14.405: E/AndroidRuntime(15746):    at com.mseiz.give.your.apps.MainSite.copyInputStreamToFile(MainSite.java:119)
11-07 15:09:14.405: E/AndroidRuntime(15746):    at com.mseiz.give.your.apps.MainSite.copyInputStreamToFile(MainSite.java:119)
11-07 15:09:14.405: E/AndroidRuntime(15746):    at com.mseiz.give.your.apps.MainSite.copyInputStreamToFile(MainSite.java:119)
11-07 15:09:14.405: E/AndroidRuntime(15746):    at com.mseiz.give.your.apps.MainSite.copyInputStreamToFile(MainSite.java:119)
11-07 15:09:14.405: E/AndroidRuntime(15746):    at com.mseiz.give.your.apps.MainSite.copyInputStreamToFile(MainSite.java:119)
11-07 15:09:14.405: E/AndroidRuntime(15746):    at com.mseiz.give.your.apps.MainSite.copyInputStreamToFile(MainSite.java:119)
11-07 15:09:14.405: E/AndroidRuntime(15746):    at com.mseiz.give.your.apps.MainSite.copyInputStreamToFile(MainSite.java:119)
11-07 15:09:14.405: E/AndroidRuntime(15746):    at com.mseiz.give.your.apps.MainSite.copyInputStreamToFile(MainSite.java:119)
11-07 15:09:14.405: E/AndroidRuntime(15746):    at com.mseiz.give.your.apps.MainSite.copyInputStreamToFile(MainSite.java:119)
11-07 15:09:14.405: E/AndroidRuntime(15746):    at com.mseiz.give.your.apps.MainSite.copyInputStreamToFile(Ma
11-07 15:09:14.420: D/dalvikvm(15746): GC_CONCURRENT freed 553K, 12% free 12644K/14343K, paused 2ms+2ms, total 12ms
11-07 15:09:14.420: D/dalvikvm(15746): WAIT_FOR_CONCURRENT_GC blocked 9ms
11-07 15:09:14.440: D/dalvikvm(15746): GC_CONCURRENT freed 324K, 11% free 12802K/14343K, paused 1ms+2ms, total 17ms
  • 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-06-13T23:07:52+00:00Added an answer on June 13, 2026 at 11:07 pm

    This line:

    readBytes(input);
    

    Does nothing. You need to write those returned bytes to the FileOutputStream. BTW, consider using org.apache.commons.io.IOUtils.copy(InputStream, OutputStream) or similar. Storing the byte array in memory can throw OutOfMemoryErrors if the downloaded files are large enough.

    UPDATE:
    Better yet:
    org.apache.commons.io.FileUtils.copyInputStreamToFile(InputStream,File)

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

Sidebar

Related Questions

I have this working code, but now i need to be able to change
This is roughly the code I'm working with now: List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
This was working..and I moved the disposal code to the finally block, and now
i got this code working and it to return the last tweet from my
Ok this code seems to be working now (ajax getting the current selection) .
I have this code working, from this example : var url = function(req, res){
xml and logcat now added, now custom view code, unfortunately i am away from
This code was working up until today now I keep getting the buffer exceeded
I have this code working in C#: var request = (HttpWebRequest)WebRequest.Create(https://x.com/service); request.Method = GET;
Why isn't this code working? I've been stuck on this for 2 days. public

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.