Problem with ZIP file download
I try to download a ZIP file from some URL. Everything goes fine, but I never get the entire content of the file (1.79 MB size).
Here a code snipet:
byte[] data = new byte[conn.getContentLength()];
Object obj = conn.getContent();
java.io.BufferedInputStream bis = (java.io.BufferedInputStream) obj;
bis.read(data);
bis.close();
File f = new File(sPath.toLowerCase());
FileOutputStream fos = new FileOutputStream(f);
fos.write(data);
fos.flush();
fos.close();
Any ideas? Thanks in advance.
Frank
I think the real problem is that you don't check the return value from read (it's probably less than data.length indicating an incomplete read). Isn't there a readFully somewhere?
Similar Messages
-
There seems to be a problem with the file download. For troubleshooting tips, please visit our customer support page.
Thank you for the update Dlawrenceusa. I would recommend reviewing the installation logs for the updates that are failing to apply to determine the exact cause of the failure. You can find details on how to locate and interpret the installation log files at Creative Cloud Help / Troubleshoot install issues with log files | CC. You are welcome to post any specific error messages you discover to this discussion.
-
Problem with URL File download
Hi every one i am facing a problem with URL File read Technique
import java.awt.Color;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
public class JarDownloader
boolean isSuccess = false;
public JarDownloader(String url)
downloadJar(url);
public boolean isDownloadingSuccess()
return isSuccess;
private File deleteExistingFile(String filename)
File jarf = new File(filename);
if(jarf.exists())
jarf.delete();
return jarf;
public static void main(String args[]){
new JarDownloader("url/filename.extension");
private void downloadJar(String url)
try
URL jarurl = new URL(url);
URLConnection urlc = jarurl.openConnection();
urlc.setUseCaches(false);
urlc.setDefaultUseCaches(false);
InputStream inst = urlc.getInputStream();
int totlength = urlc.getContentLength();
System.out.println("Total length "+totlength);
// If the size is less than 10 kb that means the linkis wrong
if(totlength<=10*1024)throw new Exception("Wrong Link");
JFrame jw =new JFrame("Livehelp-Download");
JPanel jp =new JPanel();
jp.setLayout(null);
JLabel jl = new JLabel("Downloading required file(s)...",JLabel.CENTER);
jl.setBounds(10,10,200,50);
jp.add(jl);
JProgressBar jpbar = new JProgressBar(0,totlength);
jpbar.setBorderPainted(true);
jpbar.setStringPainted(true);
jpbar.setBounds(10,70,200,30);
jpbar.setBackground(Color.BLUE);
jp.add(jpbar);
jw.setContentPane(jp);
jw.pack();
jw.setResizable(false);
jw.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
jw.setLocationRelativeTo(null);
jw.setSize(220,150);
jw.setVisible(true);
int readlngth=0;
int position=0;
byte[] readbytes = new byte[totlength];
while(totlength-position > 0)
readlngth = inst.read(readbytes,position,totlength-position);
position+=readlngth;
jpbar.setValue(position);
File jarf = deleteExistingFile(filename);
jarf.createNewFile();
//FileWriter fwriter=new FileWriter(jarf,true);
FileOutputStream fout = new FileOutputStream(jarf,true);
DataOutputStream dout = new DataOutputStream(fout);
dout.write(readbytes);
dout.flush();
dout.close();
inst.close();
jw.setVisible(false);
jw.dispose();
isSuccess=true;
}catch(Exception ex)
isSuccess=false;
}From the above code i received the total length of the PAGE content (i.e here url is a file) when i tried to find the size of that file it return -1.
please help meI think the real problem is that you don't check the return value from read (it's probably less than data.length indicating an incomplete read). Isn't there a readFully somewhere?
-
PKGBUILD problem with zip file
Hi all,
I'm trying to build Envy Code R font package. Here is the file:
pkgname=ttf-envy-code-r
pkgver=preview7
_pkgver=PR7
pkgrel=1
pkgdesc="Free scalable coding font"
arch=('i686' 'x86_64')
url="http://damieng.com/blog/tag/envy-code-r"
license=('freeware')
depends=('fontconfig' 'xorg-fonts-encodings' 'xorg-font-utils')
install=envycoder.install
source=("http://download.damieng.com/fonts/original/EnvyCodeR-$_pkgver.zip")
md5sums=('0cce55205f1e8a109021b46c24741257')
build() {
cd $srcdir/Envy\ Code\ R\ $_pkgver
install -D -m644 Read\ Me.txt $pkgdir/usr/share/licenses/$pkgname/readme.txt
mkdir -p ${startdir}/pkg/usr/share/fonts/TTF
for i in *.ttf
do
mv "$i" $(echo $i | sed -e 's/ //g')
done
install -m644 *.ttf ${startdir}/pkg/usr/share/fonts/TTF/ #Skipping what's under VS
However, 'makepkg' gave this error: -> bsdtar -x -f EnvyCodeR-PR7.zip
Envy Code R PR7/Envy Code R Bold.ttf: Write request too large
Envy Code R PR7/Envy Code R Command Prompt.reg: Write request too large
Envy Code R PR7/Envy Code R Italic.ttf: Write request too large
Envy Code R PR7/Envy Code R.ttf: Write request too large
Envy Code R PR7/Read Me.txt: Write request too large
Envy Code R PR7/Visual Studio italics-as-bold/Envy Code R VS Italic-as-bold.ttf: Write request too large
Envy Code R PR7/Visual Studio italics-as-bold/Envy Code R VS.ttf: Write request too large
bsdtar: Error exit delayed from previous errors.
I tried bsdtar -x -f with normal zip file and zip file with spaced file name and found no problem. Can anybody explain? Thanks,Certain zip files can't be handled by bsdtar; it is explained in more detail in some of the technical writeups of libarchive which processes all files as streams rather than random-access as the 'unzip' program does.
For zip files that are made in a slightly unorthodox fashion, one can do the following:
1. Add the zip file to the noextract=() PKGBUILD array
2. Add 'unzip' as a makedepend
3. Add as the first lines of your build function:
cd $srcdir
unzip <sourcefile>.zip
4. Continue as normal. -
Waas caching problem with zip files
hi,
When we send same zipped file to branches, waas does not cache that file, without zipping waas caches the file. Is there any restrictions for zip file?Hi Muhammed,
When you say that WAAS is not caching, I guess you mean that the optimization achieved is much lower than without zipping the file. Am I correct?
If that is the case, then, I'm afraid it's the expected behavior. The cause for this is DRE
In general terms, the way DRE works is by caching small chunks of a file. Later on, when these chunks are seen again in the file (either in the same connection or subsequent ones), they will not be transferred through the WAN link and instead, a chunk identifier (very small) will be sent. The problem is that all compression algorithms work in a similar way, removing repeating parts of the file to make it smaller.
The result is that, any file that is encrypted/compressed has almost no repeating patterns in it, and therefore, even though DRE is applied, the reduction ratios are minimal, sometimes even getting to the point of making transfer even slower than without it.
As a general good practice, if you are using WAAS to optimized your data transfers, make sure that the files you are transferring are neither compressed nor encrypted. This way you will get the maximum optimization ratios out of WAAS.
I hope this answers your question
Daniel -
Problem with zipping file with chinese chars
I need to zip a html page which contains some chinese characters, I am able to zip it and create a zip file
but the problem is when i open the zip file and view the html file it displays junk characters instead
of chinese characters
Here is what i am doing
ByteArrayOutputStream bStream = new ByteArrayOutputStream();
ZipOutputStream zStream = new ZipOutputStream(bStream);
ZipEntry zipEntry = new ZipEntry(htmlFilename);
zStream.putNextEntry(zipEntry);
ByteArrayOutputStream dataStream = new ByteArrayOutputStream();
PrintWriter writer = new PrintWriter(
new OutputStreamWriter(dataStream,"UTF-8"));
writer.write(htmlString); //htmlString is the string which contents the html contents which has chinese char
writer.close();
zStream.write(dataStream..toByteArray());And when you view the unzipped file, are you using something that realizes that you encoded your data using UTF-8? My guess is that you are not.
PC² -
Problem with multiple files download (OD 6.0)
Please, help me :(
I have a proble with installation of Developer 6.0 after I
downloaded multiple files and joined them.
At command prompt it says "The program is too big to fit in
memory" or something like it. (623K of conventional memory at
that time).
Do you know how to solve this problem. I will appreciate your
help very much.
Thank you.
Leonid Roodnitsky
nullPlease, help me :(
I have a proble with installation of Developer 6.0 after I
downloaded multiple files and joined them.
At command prompt it says "The program is too big to fit in
memory" or something like it. (623K of conventional memory at
that time).
Do you know how to solve this problem. I will appreciate your
help very much.
Thank you.
Leonid Roodnitsky
null -
Problem with multiple file download
Good day.
I have a code that downloads multiple files from the database and then saves it to a specified directory. I work fine but when I check the contents of the file, some of them are not complete. Lets, say I have downloaded 16 files and only file # 4,5,6,7 have the correct contents as compared to the original.
Why is that so?
my code snippet:
DiskFileUpload fu = new DiskFileUpload();
fu.setSizeMax(1000000000);
List fileItems = fu.parseRequest(request);
Iterator itr = fileItems.iterator();
while(itr.hasNext())
FileItem fi = (FileItem)itr.next();
if(!fi.isFormField())
String filen = fi.getName();
String fname = filen.substring(filen.lastIndexOf(java.io.File.separator)+1);
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
connection = DriverManager.getConnection(connectionURL, "", "");
statement = connection.createStatement();
String sql = "INSERT INTO tblTestFiles("
+ "strFileName,"
+ "imgFile) "
+ "VALUES(?,?)";
PreparedStatement pstmt = connection.prepareStatement(sql);
//Set the values for strFileName and imgFile
pstmt.setString(1,fname);
// Set the blob
//File file = new File(fnew);
FileInputStream is = new FileInputStream(filen);
pstmt.setBinaryStream(2, is, (int)filen.length());
// Insert the row
pstmt.executeUpdate();I am using eclipse 5.5.23, eclipse 3.2 with myeclipse SDK, MS SQL, Ant.sorry I posted the wrong code. here's the correct one:
statement = connection.createStatement();
rs = statement.executeQuery("SELECT strFileName,imgFile FROM tblTestFiles ORDER BY strFileName");
while (rs.next())
String filename = rs.getString(1);
Blob blob = rs.getBlob(2);
InputStream is = null;
is = blob.getBinaryStream();
int i;
String dir = "C:\\DownloadedFiles";
File path = new File(dir, filename);
FileOutputStream fos = null;
fos = new FileOutputStream(path, true);
PrintWriter pout = null;
pout = new PrintWriter(new FileOutputStream(path,true));
while ((i = is.read()) != -1)
pout.write(i);
fos.close();
pout.close();
}// end of if construct
}// end of try
catch (IOException e)
e.getMessage (); e.printStackTrace();
System.out.println(e);
catch (SQLException e)
e.getMessage (); e.printStackTrace();
System.out.println(e);
}Thanks. -
Problem with Javascript file downloaded
Hi everyone
Im totally new to downloading javascript files, and ive made
a bad mistake when installing.
I downloaded a javascript file called 'close window' to my
desktop then installed it using the
DW extension manager.
I thought after it would be a good idea to put that file then
into a javascripts behaviors folder in my program file for DW. Bad
idea!
When i loaded up DW8 again, i got lots of error messeges
(which i can post if its any help) and now i cant use any
javascripts.
Ive deinstalled the program and reinstalled the program many
times. Ive tried deleting all my personal files i created as well,
the reinstalling DW*
still the same messeges come up, ive been battling with this
for 3 hours now, please someone help!!
thanksTry uninstalling using this TechNote:
Uninstalling Studio 8 applications on Windows
http://www.adobe.com/go/4e7826b7
You could also try this TechNote:
Troubleshooting JavaScript errors in Dreamweaver
http://www.adobe.com/go/19105
Hope this helps,
David Alcala
Adobe Product Support -
Strange problems with Zip Files in Captivate/SumTotal
Ok, this is a weird one. If I publish a 1.2 SCORM course and select the zip folder option, our (horrible) SumTotal 7.6 system has no problems uploading the course. If I publish to a folder or to my desktop and place all the files in the folder and zip the file, it doesn't track as SCORM at all.
I get the same results on the ADL Test Scorm tracker. When the zip folder is uploaded, it reads as SCORM compliant. When I publish to an upzipped folder and then zip it, I get a ton of XML file not well formed and other xml errors.
The issue is that I need to make changes to the imsmanifest file to remove the SumTotal Navigation Player and resize the screen properly for the course.
The zip program we are using is "ZipGenius".
1.) Has anyone else run into this issue?
2.) Any ideas on how to fix this so that I can make changes to the imsmanifest file and still upload the course as 1.2 SCORM compliant?
Thanks,
DanKevin,
At first, I would have thought the LMS doesn't necessarily return the appropriate information for Captivate to send a score (there are several basic calls that are supposed to be sent by an LMS in SCORM to facilitate this). So, I created a custom HTM file for the Captivate 4 template... But in re-reading the thread - you are using SumTotal and I believe SumTotal does make these calls...
For the purposes of anyone else that is using an LMS and not seeing a score in their LMS (and they are using this custom template) - here is a Captivate 4 template file that forces Captivate to send a score to a SCORM LMS (though not necessarily SCORM-compliant LMS - if these calls are ignored): http://www.learningconsulting.com/Content/Macromedia/Captivate/SumTotal_Captivate4_SCORM_C ustom.zip
Kevin - I do not necessarily believe this custom template will work for you. I can send you an entire debug file I've built for helping to track down AICC/SCORM issues - but let's hold off on that, for now. Can you edit the resulting HTM file of one of your published Captivate file built using the SCORM template I've provided earlier; modify the last line in the method sendTrackingDataToLMS; uncomment out the alert statement (remove the "//"). I'd like to know what is displayed when you close the content window from SumTotal.
Regards,
Andrew -
Problem in ZIP file encryption
Hi Folks,
I am facing a problem while encrypting and decrypting a ZIP file. The result file is corrupted.
If i encrypt .txt and .doc files, i am able to get them in decryption. But problem with ZIP files. What could be the reasone?
I am using AES algorithem.
Key Generator code is:
================
KeyGenerator kgen = KeyGenerator.getInstance("AES");
kgen.init(128); //128 bitskey = kgen.generateKey();
Encryption:
========
Cipher ecipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
//paramSpec is a Initialization Vector
ecipher.init(Cipher.ENCRYPT_MODE, skey, paramSpec);
FileInputStream in = new FileInputStream("c:\\encryption\\Source.zip");
FileOutputStream out = new FileOutputStream("c:\\cipher\\cipher.enc");
OutputStream cout = new CipherOutputStream(out, ecipher);
int numRead = 0;
while ((numRead = in.read(buf)) >= 0) {
cout.write(buf, 0, numRead);
Decryption:
========
Cipher dcipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
dcipher.init(Cipher.DECRYPT_MODE, skey, paramSpec);
FileInputStream fis = new FileInputStream("c:\\cipher\\cipher.enc");
InputStream in = new CipherInputStream(fis, dcipher);
FileOutputStream fos = new FileOutputStream("c:\\encryption\\Result.zip");
int numRead = 0;
while ((numRead = in.read(buf)) >= 0) {
fos.write(buf, 0, numRead);
}bala_1404 wrote:
i closed them in the program. i just pasted important lines of my program.You have a program that does not work and you don't know why yet you feel confident enough in your diagnosis to show just the lines where you think the problem lies. I'm betting that you are closing the wrong streams but of course I am guessing since I can't see the code that matters.
Good luck. -
Problem with .sitx files (Safari but not Firefox???)
Hi All,
I have a website online (with help from iWeb and BBEdit) but am having a problem I cant figure out (this IS my first website!)
I am hoping that someone much more knowledgeable than me can help me with it.
I basically have a download section. Icons and desktops.
Now, when I (or anyone else) tries to download- everything seems to be fine in FireFox (even IE!) but not in Safari.
My desktops are compressed as .zip files. No problems there, everyone can download and open (including Safari users!)
My icons are compressed as .sitx files. This is where the problems come in. Firefox and IE download them no problem ('save to disk?' etc) However when one attempts to download the icons (.sitx files) with Safari it simply displays pages of gibberish (starting with the word 'Stuffit') which I am presuming is Safari trying to 'display' the contents of the actual stuffit file.
Why is this? Why wont safari simply download the .sitx files as it does .zip files?
Does Safari have some sort of inherent problem with .sitx files? Is it some sort of configuration within Safari preferences? or (and probably most likely!) is it something I have done wrong?
Oh, my website (page in question!) can be found here:
http://aoimedia.co.uk/news/news.html
Thanks in advance for all your valuable help
Kind regards
John
12 G4 Powerbook/Superdrive. (she's named Skates!) Mac OS X (10.4.4)Hi,
It sounds like the server the website/file is hosted on is not identifying the type correctly. As you've seen, different browsers will handle this situation differently.
Have a read of this article:
http://www.macosxhints.com/article.php?story=20040211102018600
Hope that helps. -
Zip File Download frustrations
hi there.
So, I am having some problems with some files. I'm downloading addons for an MMORPG but most of them are .zip files which is giving me a problem--they'll go to my download menu and get to a point before stopping and saying "cannot create file". I've searched other areas of the forum but haven't found out how to download and unzip (if necessary) the files.
Any help would be greatly apprecaite. Thanks!Actually, it sounds to me like you aren't having a problem opening files you have downloaded, rather it sounds like you aren't able to download things to start with due to a permissions error of some sort at the download location.
Try this:
1. Create a new folder in your home folder and name it Downloads
2. If you are using Safari, go to Safari's Preferences, click the General tab, and in about the middle you'll see "Save downloaded files to:"
3. Click the double arrows select "Other" and then navigate to your new Downloads folder and select it
4. Try downloading something again and see if it is successful
If you don't get any errors, go to your new Downloads folder and double click the downloaded item. A zip file should unzip, a .dmg file (btw, it is dmg which means "disk image") should mount like any other disk, and you can run installers or drag and drop the contents to where you want them.
Francine
Francine
Schwieder -
Problems with .ARW files and auto toning
problems with .ARW files and auto toning
let me try to explain this because this has happened in past and never found a way to resolve but i lived with it
now that I have a Sony A7R the problem is more serious
Firstly i take pride it making the picture happen all in camera, i use DRO lvl 5 to get enough light, like when i'm shooting at dusk. DRO its like doing HDR but in a single file, it lightens the darks. in my camera i'm happy with results
but when I upload them to lightroom, they come out near black.
allow me to explain
lets say I import 100 images
i double check my preferences and everything is UNCHECKED when it comes to importing options, there is no auto toning, nothing.
as the images import i see a preview in the thumbnail which looks fine.
i double click on one to enlarge it, hence leave grid view.
for a brief 1 or 2 seconds, i see the full image in all its glory but than lightroom does something funny, it darkens the image
one by one as it inspects each image, if it was a DRO image it makes it too dark.
to make this clear, the image is perfect as it was in the beginning but after a few seconds lightroom for some reason thinks it needs to correct it.
how to prevent lightroom from doing this, i want the image exactly as it is, why must lightroom apply a correction>?
i think it has to do something with interpreting the raw file and lightroom applies its own algorithm.
but here is what i dont get.....before lightroom makes the change i'm able to witness the picture exactly as it was taken and want it unchanged..
now i have to tweak each file or find a profile for it which is added work.
any ideas how to prevent lightroom from ruining my images and just leave them as they were when first detected...
there are 2 phases...one is when it originally imports and they look fine
second is scanning each image and applying some kind of toning which darkens it too much.
thanks for the helpsorry thats the auto reply message from yahoo email.
i've disabled it now
thing is, there is no DRO jpg to download from the camera
its only ARW. so my understanding is when i use DRO setting, the camera makes changes to the ARW than lightroom somehow reads this from the ARW.
but then sadly reverts it to no DRO settings.
because i notice if i take normal picture in raw mode its dark but if i apply dro to it, it comes out brighter, yet when i d/l the image from camera to lightroom, which is an ARW - there are no jpgs. lightroom decides to mess it up
so in reality there is no point in using DRO because when i upload it lightroom removes it.
is there a way to tell lightroom to preserve the jpg preview as it first sees it.
its just lame, picture appears perfect...than lightroom does something, than bam, its ruined,.
what do i need to do to prevent lightroom from ruining the image? if it was good in the first place. -
I receive many e-mails with zipped files. I can no longer open or unzip my files. A window welcoming me to Application Loader drops down. It prompts for an iTunes Connect login, but will no accept my iTunes login. I have no way to open or unzip my files. Help!!!!
Application Loader, unless there's another one I'm not familiar with, is part of the iOS SDK. That have usurped the .zip, or you may have removed that application but your Mac is still holding onto the mapping of Zip files to that application. Select a .zip file in Finder, Get Info, and go to the Open with section. Select Archive Utility and click Change All. That should fix the problem.
Regards.
Maybe you are looking for
-
Early Imac 20" freezes on regular mode but works fine in safe mode, any ideas?
Have a early 2006 Imac 20" that won't run in normal mode; freezes within minutes. Run fine in safe mode, but safe mode won't play sound or allow exterior inputs. In high fan state, don't know the name of the mode, but you hold the power button whil
-
Hi all, I have a user who encounter an error which looks like this when she runs the G/L Account Line Item Display. "Exception #1 has occurred and dumped to this file: C:\Document and settings\user-name\SapWorkDir\FrontExceptions_3776_3264.trc Press
-
How to store R-tree in Orace?
Hi,every bady! Who knows that how to store R-tree in Orace?In other words,R-Tree is the order stored in memory or a random store? any help would be appriciated lgs
-
hai everyone, i have done a small databse application in Sun creator studio with MySql as backend.It worked well with with the sun application server. but when the same is deployed on tomcat , i met with the following error Exception Handler Descript
-
Cannot add presets in Distiller 10.1.5?
I am unable to add or edit presets in Distiller 10.1.5. I have added joboptions files before, but I am unable to do so now. I am able to edit/save as presets so I could do this manually if I had the printer's specs. I have added a new joboptions file