• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Unable to download small sized PDF files properly

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All
I'm trying to download a pdf files from FTPServer. I was able to download the file but when i'm trying to open the same, i'm unable to see the contents.
FYI-If the PDF file size is 735kb, i'm able to see the contents. But if the file size is 18kb, i'm unable to see the contents of the PDF File.

I'm pasting the code which i was using to download,

//The following stmt, gets the file contents in the form of byte array.

byte [] aFileContent = ftpClient.downloadFile("csfbsda.pdf");
InputStream is = new ByteArrayInputStream(aFileContent);
BufferedInputStream in = new BufferedInputStream(is);
FileOutputStream file = new FileOutputStream("C:/csfbsda.pdf");
BufferedOutputStream out = new BufferedOutputStream(file);
 
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try flushing the output stream By the way, you seem to have lost your way...
 
Purna Nagabhyru
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Thanks for your reply. The same what you have mentioned i'm already using that in my code. But not succeded. In the previous mail i haven't posted that code, please find the total code,


//Calling file download method of FTPClient to download "abcd.pdf".

byte []afileContent = ftpClient.downloadFile("abcd.pdf");

InputStream is = new ByteArrayInputStream(aFileContent);
BufferedInputStream in = new BufferedInputStream(is);

//Storing the file on to our local machince.
FileOutputStream file =
new FileOutputStream("C:/abcd.pdf");
BufferedOutputStream out = new BufferedOutputStream(file);
int i;
out.flush();
while ((i = in.read()) != -1) {
out.write(i);
}

out.flush();
out.close();
 
I've read about this kind of thing at the checkout counter. That's where I met this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic