いまいち入出力系は苦手・・・
まあ、要するにInputStreamを作って出力したい形式のOutputStreamに
書き出せばいいんだね。
URL url = new URL(path);
InputStream is = url.openStream();
ByteArrayOutputStream b = new ByteArrayOutputStream();
OutputStream os = new BufferedOutputStream(b);
int c;
try {
while ((c = is.read()) != -1) {
os.write(c);
}
} catch (IOException e) {
throw e;
} finally {
if (os != null) {
try {
os.flush();
os.close();
} catch (IOException e) {
// do nothing
}
}
}
byte[] buf = b.toByteArray();
まあ、要するにInputStreamを作って出力したい形式のOutputStreamに
書き出せばいいんだね。
URL url = new URL(path);
InputStream is = url.openStream();
ByteArrayOutputStream b = new ByteArrayOutputStream();
OutputStream os = new BufferedOutputStream(b);
int c;
try {
while ((c = is.read()) != -1) {
os.write(c);
}
} catch (IOException e) {
throw e;
} finally {
if (os != null) {
try {
os.flush();
os.close();
} catch (IOException e) {
// do nothing
}
}
}
byte[] buf = b.toByteArray();