[Verifying Downloads] Java-Downloaded file not same filesize as on server

This is in the security forum, but really involves a few details:
1.) My program downloads files from a server
2.) I have precalculated hash md5 values and file sizes in a .cfg file in the server which is also downloaded
3.) The md5 is calculated of the downloaded files
4.) The filesize is checked and the md5s are checked
I have 4 client windows computers I've tested this on. It worked on 3. The fourth has a strange behavior: About every other file would have ~ 8 additional bytes in the filesize. I have no idea where those bytes are coming from, everytime it redownloads, same filesize, albeit 8 bytes too big. Therefore, the Md5 is screwed up.
Here's my downloading from server code:
OutputStream out = null;
          InputStream  in = null;
          try {
               URLConnection dat = online.openConnection();
               local.getParentFile().mkdirs();
               out = new FileOutputStream(local);
               while(true){
                    try {
                         in = dat.getInputStream();
                         break;
                    } catch (ConnectException e){
                         System.err.println("Couldn't contact server!");
               byte[] buffer = new byte[1024];
               int numRead;
               tsecago = System.nanoTime();
               readbytessecAgo = -1;
               while ((numRead = in.read(buffer)) != -1) {
                    out.write(buffer, 0, numRead);
                    readbytes += numRead;
          } catch (Exception e){
               e.printStackTrace();
          } finally {
               try {
                    if (in != null) {
                         in.close();
                    if (out != null) {
                         out.close();
               } catch (IOException ioe) {
          }SO, my solution was as follows:
1.) Download file once and check md5 & filesize
2.) If failed, download file AGAIN and check md5 & filesize
3.) If failed 2x, download file for last time and check filesize - if the filesize is within 40 bytes of the actual file, allow it.
This now works on all 4 computers, and as far as I can tell the downloaded files are wholly correct.
But this is really annoying! Why is the above download code producing 8 extra bytes?!

Thanks for your reply, Timo, and John, the same file downloading is working fine with my Integrated weblogic server, but the same application when i deployed in my DEV server i am getting the error.
Code which i am trying to download file is
public void downloadCardInserts(FacesContext facesContext,
OutputStream outputStream) throws FileNotFoundException,
IOException {
// Add event code here...
UploadedFile filename=(UploadedFile)browseFile.getValue();
String fname=filename.getFilename();
String fname1="//bwi-wfp-v01/Apps/SCII/TEST/LOG/Cards/RENEWAL/"+fname;
System.out.println("file name11111:"+fname1);
FileInputStream in = new FileInputStream(new File(fname1));
byte[] buffer = new byte[1024];
int bytes = in.read(buffer);
while (bytes >= 0) {
outputStream.write(buffer, 0, bytes);
bytes = in.read(buffer);
}

Similar Messages

  • Failed to download java download client

    Trying to get a webex meeting going w/new firefox 4 install, I get:
    "Failed to download java download client!
    Sorry, you do not have java download client enabled. Please try again or inform your Site Administrator to set up for you. "
    There is no site administrator, it's my Mac so I'm it. ;) I've googled it and I see nothing on how to turn this on. Basically you can try and start a webex meeting here:
    http://www.webex.com/lp/jointest/
    That also chokes with the same error. Works with Firefox 3.x no problems... but with firefox 4 no dice. Probably some simple setting I'm missing... can someone give me a clue?

    Workaround:
    Find your Firefox application in Finder, right click on it, click on "File Info", select 32-bit mode, and restart Firefox.

  • Why will my java.jar file not open

    Why will my java.jar file not open

    This is the iPod touch forum. Do you have a question concerning an iPod touch? The iPod touch does not run Java.
    If you have a new Mac you have to download the Java program to run Java on a Mac. It no longer comes with the iOS.

  • I've just changed from a PC to a mac and have a large number of downloaded WMA music files (not i-tunes purchases) which I just can't get into my i-tunes library. File converters don't seem to work either. Any ideas?

    I've just changed from a PC to a mac and have a large number of downloaded WMA music files which I can't get into i-tunes. When the library was in Windows, i-tunes would convert the files automatically, but this doesn't happen now. I've downloaded a couple of file converters, but these don't seem to work either. Any ideas?

    iTunes for Windows (but not iTunes for Mac) can import and convert unprotected WMA tracks. If the tracks are protected by DRM (Digital Rights Management) then it will not accept them.
    One option would be to install iTunes on your PC, do the conversion, and then transfer the converted tracks from iTunes on your PC to iTunes on your Mac.

  • Cannot download PS6- error 'file not found'. PS CC downloads fine.

    getting error 'file not found' when try download PS 6 on CC website.  PS CC downloaded fine using CC app but
    PS 6 is not available when using app.

    Hi cbcart,
    Please try downloading Photoshop CS6 from the mentioned link: http://helpx.adobe.com/x-productkb/policy-pricing/cs6-product-downloads.html.
    Regards,
    Romit Sinha

  • Item not downloading because URL could not be found on this server?

    I was attempting to download an audio book from the itunes store and it said the URL <insert url here which is too long and I could not copy from the error window> could not be found on this server, How do I get my download or atleast a refund to my account?

    Contact iTunes customer support.

  • Java.io.File not found in JDK 1.4

    why the java.io.file is deprecated.
    Frans

    [fthamura],
    why the java.io.file is deprecated.Probably because in J2SE 1.4, the New I/O package java.nio package provides scalable I/O operations for files. Through the File channels, a programmer will be able to provide memory-mapped buffers, improved file locking mechanism and faster I/O transfers with the new API package.
    FransHTH.
    Allen Lai
    Developer Technical Support
    SUN Microsystems
    http://www.sun.com/developers/support/

  • SQLPLUS: How to verify that java class file have been loaded

    Hi All,
    I just loaded my Java class file using CREATE OR REPLACE JAVA.
    Java was created sucessfuly, but how can I check or find out if my file have been loaded correctly.
    I also found a command :
    SQL>exec myjava.showobjects
    but i don't have the loadjava utility install....is there any command from SQL PLUS?
    thanks

    Thanks for the sql command....after that query what do I do next to see if for example tree.class is in the dba_object.
    Sorry, I am a newbie and the question may be a bit generic .....

  • Getting 'File not found' error while using server object model code

    Hi,
    I am using server object model code to pull list data in a console application. My machine has standalone installation of SP 2010. I am getting error 'File Not Found', however the same operation is working fine with client object model code.
    Code I am using:
    string strURL=http://servername/sites/sitename;
    SPSite siteObj=new SPSite (strURL); //getting error here.
    I have already checked the below,
    1. Framework being used is 3.5.
    2. I have proper access to site.
    3. Running visual studio as admin.
    Any help is much appreciated.
    thanks
    Tarique
    thanks and regards Tarique Aslam

    Hello Tarique ,
    Couple of pints need to check:
    1. User running the console application needs to have at least read permission to the SharePoint databases
    2. Set application by changing the "Platform target:" option on the "Build" to "Any CPU"
    Also refer this similar thread:
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/2a419663-c6bc-4f6f-841b-75aeb9dd053d/spsite-file-not-found
    Hope it could help
    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

  • SWF File not working after upload to server, but works on local system

    HELP PLEASE.....I have created a Fla and exported a swf file
    from Flash 8 and Export (Flash 6). I can preview the page in
    Dreamweaver just fine, but when i upload it and the html file, it
    isn't showing up. It leaves a blank spot on the page. It is just a
    simple banner with graphic clips and motion tween text, with image
    bgd. All images are jpg.
    I have tried:
    1. Using a full link to the swf file.
    2. Removed drop-shodows in swf file
    3. convert to Flash mx 2004 file
    4. Exported to higher Flash version to see if the flash
    player was an issue.
    5. Exported with no dashes in name
    6. Added Scr file into Dreamweaver
    7. Made a new test file to see if it was something in the
    current html doc, same result.
    8. Tried viewing on a pc, same result. Created on mac.
    Here is the test page if anyone wants to take a look.
    THANKS FOR ANY ADVISE.
    Test
    Page Link

    The link you provided is to the SWF file, not to an HTML
    file, so no one can test your HTML file.
    Have you checked the code for the embedding of the SWF file
    in your HTML file? I don't use Dreamweaver much, but I do know that
    if you start assembling a Dreamweaver file without first saving the
    HTML, embedded graphics and other items are inserted as direct
    links to the files on your computer, rather than as relative paths.
    There is one other possible issue: I note that your swf is
    called CWABanner.swf. Depending on your FTP settings, it is
    possible that your server is forcing all file names to lower case
    (a common practice). Which means the file on your server will be
    cwabanner.swf. Again, depending on how the web server is set up, if
    it is case sensitive, it will treat CWABanner and cwabanner as
    separate files. So if the HTML calls CWABanner.swf, but the FTP
    upload has forced a rename to lower case to cwabanner.swf, the HTML
    file will not find it. Check this out, or to be absolutely certain,
    rename everything to lower case: the file name itself and the
    reference in the HTML file.

  • Tone alert downloaded into music file not in sound files how do I move them there

    I downloaded a email alert and one for text alert from iTunes .Ithought they would go in to the list of sounds on my iPad2 but instead they are in my music list.Can I transfer them to my sound list?

    I also did this after spending hours with Apple Reps about my lost tones. They said that I should BUY them on the Itunes Store and they would automatically show up in Tones. I did. They still don't. If they advertise them on the store as Ringtones, then they ought to show up as Tones. I see another 3 hour session with Apple for me, and no time slot to do that.
    This is NOT just my issue. I have friends with the same problem. It needs to be fixed by Apple!

  • Where to download java jar file with org.apache.xml.serialize.OutputFormat?

    Dear Friends,
    I try one program, it import org.apache.xml.serialize.OutputFormat;
    but I cannot fine it after I google a while.
    where can I find and download jar file that contain this:
    org.apache.xml.serialize.OutputFormat
    I use JDK1.6
    Thanks
    sunny

    So, to clear things up, there is no org.apache.xml.serialize.OutputFormat.JAR
    OutputFormat is a class.
    As I said in my previous post if you go at the xerces project home page (here) you will find a compiled version of xerces [here - direct link -> (fool proof)|http://archive.apache.org/dist/xml/xerces-j/Xerces-J-bin.1.4.4.zip]. If you extract the archive you will find a compiled jar called xerces.jar. Open that one with winrar/winzip or whatever, browse to org\apache\xml\serialize\OutputFormat.class and there you go, you have it, just link this xerces library to your project...
    PS. Try searching on Google for "Google tutorial"

  • Where I can download Java 3D SDK ( not API !!!! ) ?

    I can't find in this web page ....
    Help. Please.
    Thx. Numael

    check out https://java3d.dev.java.net/

  • Java Apps Files Not Working - N 500

     I Have N 500 Symbyan Belle Refresh--Now Its Not Working Any f .Jar or jad Files Also .Sis Files Working Corect Plz Help Me..

    Also have this problem.    We also used to point our java app shortcuts to the system32 or syswow64, but with Java 8 this is no longer an option.  Updating shortcuts every time there is a new java version is unrealistic.  Similar to Jeff, the symlinks in the ProgramData folder don't seem to work.

  • Corrupt sparseimage file (not same old Filevault issue)

    I'm having a problem -- I have a corrupt Sparseimage file, but none of the solutions that others have proposed have worked.
    No matter what I try, it keeps getting reported as corrupt.
    For example, the "half mount" tip that others have used to recover things:
    $ sudo hdid -nomount SecureSparse.sparseimage
    Password:
    hdid: attach failed - corrupt image
    That's all I can get. Launching it in the finder gives me the same thing, only in a dialog box.
    Trying to verify or repair it in Disk Utility does the same.
    The most verbose response I've gotten out of any utility is this:
    $ hdiutil convert -format UDZO -verbose -o disk.dmg SecureSparse.sparseimage
    hdiutil: convert: processing "SecureSparse.sparseimage"
    DIBackingStoreInstantiatorProbe: interface 0, score 100, CBSDBackingStore
    DIBackingStoreInstantiatorProbe: interface 1, score -1000, CRAMBackingStore
    DIBackingStoreInstantiatorProbe: interface 2, score 200, CCarbonBackingStore
    DIBackingStoreInstantiatorProbe: interface 3, score -1000, CDevBackingStore
    DIBackingStoreInstantiatorProbe: interface 4, score -1000, CCURLBackingStore
    DIBackingStoreInstantiatorProbe: interface 5, score -1000, CVectoredBackingStore
    DIBackingStoreInstantiatorProbe: selecting CCarbonBackingStore
    DIFileEncodingInstantiatorProbe: interface 0, score -1000, CMacBinaryEncoding
    DIFileEncodingInstantiatorProbe: interface 1, score -1000, CAppleSingleEncoding
    DIFileEncodingInstantiatorProbe: interface 2, score -1000, CEncryptedEncoding
    DIFileEncodingInstantiatorProbe: nothing to select.
    DIFileEncodingInstantiatorProbe: interface 0, score -1000, CUDIFEncoding
    DIFileEncodingInstantiatorProbe: nothing to select.
    DIFileEncodingInstantiatorProbe: interface 0, score -1000, CSegmentedNDIFEncoding
    DIFileEncodingInstantiatorProbe: interface 1, score -1000, CSegmentedUDIFEncoding
    DIFileEncodingInstantiatorProbe: interface 2, score -1000, CSegmentedUDIFRawEncoding
    DIFileEncodingInstantiatorProbe: nothing to select.
    DIDiskImageInstantiatorProbe: interface 0, score 0, CDARTDiskImage
    DIDiskImageInstantiatorProbe: interface 1, score 0, CDiskCopy42DiskImage
    DIDiskImageInstantiatorProbe: interface 2, score -1000, CNDIFDiskImage
    DIDiskImageInstantiatorProbe: interface 3, score -1000, CUDIFDiskImage
    DIDiskImageInstantiatorProbe: interface 5, score -100, CRawDiskImage
    DIDiskImageInstantiatorProbe: interface 6, score -100, CShadowedDiskImage
    DIDiskImageInstantiatorProbe: interface 7, score 1000, CSparseDiskImage
    DIDiskImageInstantiatorProbe: interface 8, score -1000, CCFPlugInDiskImage
    DIDiskImageInstantiatorProbe: interface 9, score -100, CWrappedDiskImage
    DIDiskImageInstantiatorProbe: selecting CSparseDiskImage
    DIDiskImageNewWithBackingStore: CSparseDiskImage
    DIDiskImageNewWithBackingStore: instantiator returned 103
    convert: unable to recognize "SecureSparse.sparseimage":
    corrupt image.hdiutil: convert: result: 103
    hdiutil: convert failed - corrupt image
    I am somewhat desperate here. I have several backups of this sparse file, but they are ALL CORRUPTED IDENTICALLY. (My machine syncs to the backup server every night, and apparently it synced after the corruption happened, and clobbered the un-corrupted version.)
    Does anyone have any idea how to interpret the above messages? I'd be interested in just knowing why this happened for a start, and in what way the file is corrupted...I'm willing to invest significant resources in recovering the data.
    Most of the recovery utilities I've seen will only work if Mac OS X will partially mount the image, and that isn't the case here.
    Power Macintosh G5 Dual 2GHz   Mac OS X (10.4.6)  

    Does anyone have an answer to this. Lots and Lots of data lost.
    The tail of
    hdiutil attach -debug myimage.sparseimage
    syncPhysicalAndLogicalForkLengths: returning 0 (cached logEOF: 3592318976, physEOF: 3592318976)
    CBSDBackingStore::closeDataFork: about to close 5CSparseFile::~CSparseFile: WARNING flushing header and index nodes failed. Invalid argument
    syncPhysicalAndLogicalForkLengths: entry (cached logEOF: 3592318976, physEOF: 3592318976)
    : returning 0 (new cached logEOF: 3592318976, physEOF: 3592318976)
    DIDiskImageNewWithBackingStore: returning 0x00000067
    DIResolveBackingStoreToDiskImage: unable to resolve to any disk image class. 103.
    DIResolveURLToDiskImage: resolving disk image format failed. 103.
    status proc called: attach
    error code: 103
    status proc called: cleanup
    2006-05-25 18:36:04.170 diskimages-helper[547] DIHelperAttach performOperation: returning 103
    2006-05-25 18:36:04.170 diskimages-helper[547] DIHelper perform_operation: returning {payload = {}; "result-code" = 103; }
    2006-05-25 18:36:04.170 hdiutil[546] connectToFramework: proxy has finished operation
    2006-05-25 18:36:04.171 hdiutil[546] results are: {payload = {}; "result-code" = 103; }
    2006-05-25 18:36:04.171 hdiutil[546] _threadResultsError is 103
    2006-05-25 18:36:04.171 hdiutil[546] connectToFramework: terminating proxy
    2006-05-25 18:36:04.171 diskimages-helper[547] terminateHelper
    DIHLDiskImageAttach() returned 103
    <CFDictionary 0x323870 [0xa08011c0]>{type = immutable, count = 0, capacity = 0, pairs = (
    hdiutil: attach failed - corrupt image
    nebula:/Volumes/Europa/bad/Disk Images cgraham$ 2006-05-25 18:36:04.272 diskimages-helper[547] -DIHelperAgentMaster terminateUIAgentConnection
    2006-05-25 18:36:04.272 diskimages-helper[547] -exitIfPossible:0 (_drivesServed 0)
    2006-05-25 18:36:04.273 diskimages-helper[547] -exitWatchThread: trying to get exit lock
    2006-05-25 18:36:04.273 diskimages-helper[547] -exitWatchThread: got exit lock
    2006-05-25 18:36:04.273 diskimages-helper[547] -exitWatchCompleted:0
    2006-05-25 18:36:05.273 diskimages-helper[547] suicide:<NSCFTimer: 0x320770>

Maybe you are looking for

  • Is it possible to transfer the temperature readings through "Serial I/O" port of Lakeshore temperature monitor?

    With this monitor, you can have 2 analog outputs that you can transfer to the computer by using DAQ boards. In my case, I need temperature measurements at 3 different locations so I need 3 analog outputs, which is not possible with this device. Howev

  • Calling a webservice having an abstract element

    hi , I want to call a webservice which takes one element namely "data" as part of request info.But "data" is of abstract type and "EnterpriseData" is another element which is of type "data" . So when I form the request object as <mx:request> <data></

  • Calling amethod in comp1 from comp2

    Hi I have dc with 2 components controllers, ihave a method in comp1 i need to call that method from comp2 can u please tell me the process how to do it. Thanks rahul

  • RFDOPR10 dynamic selection to add customer group field

    Hello, I am trying to add the customer group field in the dynamic selection option, when running the RFDOPR10 report. I don't seem to find the option to add the customer group field (KNVV-KDGRP). I tried looking in the config, but was not able find t

  • OBIEE 11G help with report design

    Hi, I need to design a report in the following format Customer Number: Customer Name: Customer Address: Order Detail: Line number | Order No | Order description | Order Status The order detail will have multiple lines, I have to do this in both Excel