What i'm doing is just unzip and upload a zip file ,which can be download from a website, on to a hdfs. And here's the code:
String src="http://corpus.byu.edu/wikitext-samples/text.zip";
String dst = "hdfs://cshadoop1/user/hxy162130/assignment1";
InputStream a = new URL(src).openStream();
System.out.println(a == null);
ZipInputStream in = new ZipInputStream(a);
System.out.println(in == null);
ZipEntry zE = in.getNextEntry();
System.out.println(zE == null);
As you see, I used openStream method to change the url into inputstream, and then use the inputstream as a parameter of the ZipInputStream.Finally i get an entry from the zipinputStream. But the problem is the getNextEntry method returns a null value, which means the output of my code is false,false,true. And i just can't find where the problem is.
The HTTP request to http://corpus.byu.edu/wikitext-samples/text.zip results in an
301 Moved Permanently
giving newLocation: https://corpus.byu.edu/wikitext-samples/text.zip
. So there is not aZIP
resource avaliable any more using thisURL
.To follow redirections you could do: