2017-07-04 17 views
5

मैं जावा - SRTM files का उपयोग करके इस यूआरएल से डाउनलोड ज़िप फ़ाइलों को बैच करने की कोशिश कर रहा हूं और इसे डाउनलोड करने के लिए उपयोगकर्ता नाम/पासवर्ड की आवश्यकता है और मैं निम्नलिखित जावा कोड का उपयोग कर रहा हूं और यह मुझे निम्नलिखित अपवाद देता हैजावा 9 ज़िप अंत हैडर नहीं मिला अपवाद

java.util.zip.ZipException: zip END header not found 
at java.util.zip.ZipFile$Source.zerror([email protected]/ZipFile.java:1210) 
at java.util.zip.ZipFile$Source.findEND([email protected]/ZipFile.java:1119) 
at java.util.zip.ZipFile$Source.initCEN([email protected]/ZipFile.java:1126) 
at java.util.zip.ZipFile$Source.<init>([email protected]/ZipFile.java:963) 
at java.util.zip.ZipFile$Source.get([email protected]/ZipFile.java:933) 
at java.util.zip.ZipFile.<init>([email protected]/ZipFile.java:213) 
at java.util.zip.ZipFile.<init>([email protected]/ZipFile.java:145) 
at java.util.zip.ZipFile.<init>([email protected]/ZipFile.java:159) 
at toposwapper.rules.ZipFileDownloadAction.execute(ZipFileDownloadAction.java:29) 

यह जावा के अपने संस्करण है

java openjdk version "9-internal" 
OpenJDK Runtime Environment (build 9-internal+0-2016-04-14-195246.buildd.src) 
OpenJDK 64-Bit Server VM (build 9-internal+0-2016-04-14-195246.buildd.src, mixed mode) 

इस कोड है कि मैं डाउनलोड करने के लिए उपयोग कर रहा हूँ है -

URL url1 = null; 
    URLConnection conn = null; 
    InputStream inputs = null; 
    FileOutputStream out = null; 
    try 
    { 
     url1 = new URL(url); 
     conn = url1.openConnection(); 
     conn.setDoInput(true); 
     conn.setDoOutput(false); 
     conn.setRequestProperty("file-name", output.getName()); 
     conn.setRequestProperty("content-type","application/zip"); 
     String userpass = this.username + ":" + this.password; 
     String basicAuth = "Basic " + javax.xml.bind.DatatypeConverter.printBase64Binary(userpass.getBytes()); 
     conn.setRequestProperty("Authorization",basicAuth); 
    } 
    catch (MalformedURLException ex) { 
      Logger.getLogger(SrtmDownloadManager.class.getName()).log(Level.SEVERE, "", ex); 
    throw new TopoSwapperException(ex.getMessage()); 
    } 
    catch (IOException ioe) 
    { 
    Logger.getLogger(SrtmDownloadManager.class.getName()).log(Level.SEVERE, "", ioe); 
    throw new TopoSwapperException(ioe.getMessage()); 
    } 

    try 
     { 
     inputs = conn.getInputStream(); 
     out = new FileOutputStream(output); 
     byte[] b = new byte[1024]; 
     int count; 
     while ((count = inputs.read(b)) > -1) 
      { 
      out.write(b,0,count); 
      } 
     out.flush(); 
     inputs.close(); 
     out.close(); 

     } 
    catch (FileNotFoundException ex) 
    { 
     throw new TopoSwapperException(ex.getMessage()); 
    } 
    catch (IOException ex) 
    { 
    Logger.getLogger(SrtmDownloadManager.class.getName()).log(Level.SEVERE, "", ex); 
    throw new TopoSwapperException(ex.getMessage()); 
    } 
finally 
    { 
     close(inputs); 
     close(out); 
    } 

क्या कोई मेरी मदद कर सकता है यह क्यों विफल रहता है?

+3

चूंकि जावा 9 अभी भी बीटा में है, पहले नवीनतम संस्करण में अपग्रेड करने का प्रयास करें, शायद यह जेडीके में बस एक बग है जिसे पहले ही तय कर दिया गया है। मुझे कुछ अपवादों का उल्लेख किया गया है: https://bugs.openjdk.java.net/browse/JDK-8170276 https://bugs.openjdk.java.net/browse/JDK-8172872 –

+0

@AdamMichalik - संकेत के लिए धन्यवाद प्रतिक्रिया। तो उबंटू 16.04 पर मैं अपग्रेड कैसे करूं? :) बस एक और स्थापित करें? – gansub

+0

@AdamMichalik - बेहतर विकल्प jdk-8 स्थापित करना होगा? – gansub

उत्तर

5

जावा 9 के लिए कुछ (पहले से बंद) कीड़े हैं जो इस अपवाद का उल्लेख करते हैं (उदाहरण के लिए JDK-8170276, JDK-8172872)। चूंकि जावा 9 अभी भी बीटा में है और आप एक साल पहले (2016-04-14 बनाम जुलाई 2017 के लेखन के समय) से एक संस्करण का उपयोग कर रहे हैं, आपको नवीनतम जावा 9 ईए रिलीज में अपग्रेड करना चाहिए या जावा 8 पर चिपकना चाहिए जावा 9 की सार्वजनिक रिलीज तक।

संबंधित मुद्दे