public static byte[] readFileByBytes(String filePath) throws IOException { File file = new File(filePath); if (!file.exists()) { throw new FileNotFoundException(filePath); } else { ByteArrayOutputStream bos = new ByteArrayOutputStream((int)file.length()); BufferedInputStream in = null; try { in = new BufferedInputStream(new FileInputStream(file)); int bufSize = 1024; byte[] バッファ = 新しいバイト[bufSize]; ブール値 var6 = false; int len; while(-1 != (len = in.read(buffer, 0, bufSize))) { bos.write(buffer, 0, len); byte [ byte[] var7 = bos.toByteArray(); var7 を返します。 最後に { try { if (in != null) { in.close(); catch (IOException var14) { var14.printStackTrace (); bos.close (); } }
JavaはローカルファイルをメモリのBYTE配列に読み込みます
おすすめ
転載: blog.csdn.net/yz18931904/article/details/127594221
おすすめ
ランキング