简体   繁体   English

如何将二进制文件读入100字节长的数组

[英]How to read binary file in to a 100 bytes length array

I want to read a binary file in to a byte array, not in to a single byte array but in to a 100 bytes length array, maybe with a loop... 我想读取一个二进制文件到一个字节数组,而不是一个单字节数组,而是一个100字节长的数组,可能有一个循环......

public void readBinaryFile()
    {
        byte data[] = null;
        try {
            Path path1 = Paths.get("image.jpg");
            data = Files.readAllBytes(path1);
        } catch (Exception e) {

            System.out.println("file reading error!!!");
        }

        System.out.println("img length: "+data.length);

    }

我为此目的使用我的JBBP库 ,它允许将二进制文件部分广告解析为只读标头,例如,您可以在库的测试中找到一些用法示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM