- ★★Java質問・相談スレッド169★★
235 :デフォルトの名無しさん[sage]:2014/06/13(金) 21:35:14.86 ID:AJ/dd/iv - じゃあこんぐらいでどうですか
public static byte[] readAllBytes(String filename) throws IOException { ByteArrayOutputStream ret = new ByteArrayOutputStream(); FileInputStream fis = new FileInputStream(filename); try { byte[] readBuf = new byte[1024 * 1024]; int readSize; while ( (readSize = fis.read(readBuf)) > 0 ) ret.write(readBuf, 0, readSize); } finally { try { fis.close(); } catch ( Exception ex ) { } } return ret.toByteArray(); }
|
|