public static ByteBuffer readFileToByteBuffer(String filepath1)
{
try
{
File file1 = new File(filepath1);
InputStream is= new FileInputStream(file1);
ByteArrayOutputStream out= new ByteArrayOutputStream();
int count = 0;
byte[] b = new byte[ 8 * 1024];
while( (count=is.read(b)) != -1 )
out.write(b,0,count);
is.close();
return ByteBuffer.wrap(out.toByteArray());
}
catch(Exception e)
{
return null;
}
}
将图片文件转换为ByteBuffer
最新推荐文章于 2024-07-13 02:19:23 发布