ネタ心者歓迎!今更ながらにJava相談室 その4
■ このスレッドは過去ログ倉庫に格納されています
0674デフォルトの名無しさん
NGNGまず、read() 一発で全データを読める保証が無いということに気づけ。
それから、質問するなら相手に意図の伝わる日本語書け。
InputStream in = null;
byte[] buffer = new byte[1024];
ByteArrayOutputStream out = new ByteArrayOutputStream();
try{
in = url.openStream();
while(true){
int len = in.read(buffer);
if(len < 0) break;
out.write(buffer);
}
} catch(IOException ex){
ex.printStackTrace();
} finally {
try{
if(in != null) in.close();
} catch(IOException ex){
ex.printStackTrace();
}
}
return out.toByteArray();
■ このスレッドは過去ログ倉庫に格納されています