java通过文件路径下载文件
解决方法:
InputStream is=null;
OutputStream os=null;
try {
String fName = path.trim();
String file_name = fName.substring(fName.lastIndexOf("/")+1);
代码:http://www.yayihouse.com/yayishuwu/chapter/1980
byte bf[]=new byte[1024];
int length=0;
while((length=is.read(bf, 0, 1024))!=-1){
os.write(bf, 0, length);
}
os.flush();
} catch (IOException e) {
e.printStackTrace();
}finally {
try {
is.close();
os.close();
} catch (IOException e) {
e.printStackTrace();
}
}