留言板

File reading is not happening through the InputStream

Logu R,修改在7 年前。

File reading is not happening through the InputStream

New Member 帖子: 10 加入日期: 15-5-15 最近的帖子
The file reading is not happening through the Input Stream, especially while downloading the file from https url.

Able to pass the authentication, by using the below statement.
con.setRequestProperty ("Authorization", "Basic " + loginPassword);

Please find the code below
url = new URL(fileURL);
con = url.openConnection();
con.setRequestProperty ("Authorization", "Basic " + loginPassword);
InputStream is = con.getInputStream();
OutputStream os = new FileOutputStream(saveDir);

while ((i = is.read()) != -1) {
os.write(BUFFER_SIZE,0,i);
//System.out.println("file downloaded");
}

Can any one please assist on this.