![]() ![]() ![]() ![]() |
|||||
|
|||||
樓主 游雯仲 ![]()
![]() |
throws MalformedURLException, IOException { BufferedInputStream in = null; FileOutputStream fout = null; try { try { in = new BufferedInputStream(new URL(urlString).openStream()); fout = new FileOutputStream(filename); } catch (IOException e) { // TODO: handle exception e.printStackTrace(); }catch(Exception e){ e.printStackTrace(); } final byte data[] = new byte[1024]; int count; while ((count = in.read(data, 0, 1024)) != -1) { fout.write(data, 0, count); } } finally { if (in != null) { in.close(); } if (fout != null) { fout.close(); } } } 我是用for迴圈不斷執行這行程式來存取網路上的東西 只是程式執行到一半都會卡在這一行 ↓ in = new BufferedInputStream(new URL(urlString).openStream()); 卡的時間不一定 有時候跑個5次就卡 有時候跑50次才卡也有 不知道問題是出在哪 請版上的高手提點
搜尋相關Tags的文章:
[ openStream ] ,
本篇文章發表於2015-12-05 20:05 |