标签:style blog http io color sp for java on
private boolean downloadFile(String httpUrl, String savePath) { int byteread = 0; try { URL url = new URL(httpUrl); URLConnection conn = url.openConnection(); InputStream inStream = conn.getInputStream(); FileOutputStream fs = new FileOutputStream(savePath); byte[] buffer = new byte[1204]; while ((byteread = inStream.read(buffer)) != -1) { fs.write(buffer, 0, byteread); } System.out.println(savePath+" download finished!"); return true; } catch (MalformedURLException e) { e.printStackTrace(); return false; } catch (IOException e) { e.printStackTrace(); return false; } }
标签:style blog http io color sp for java on
原文地址:http://www.cnblogs.com/zhangfei/p/4153797.html