0
Public static void main(String[] args) {
  File inFile = null;
  if (0 < args.length) {
      inFile = new File(args[0]);
  }

    BufferedInputStream bStream = null;

    try {

        int read;
        bStream = new BufferedInputStream(new FileInputStream(inFile));

        while ((read = bStream.read()) > 0) {
            getMarker(read, bStream);
            System.out.println(read);
        }
    }
    catch (IOException e) {
        e.printStackTrace();
    } 

    finally {
        try {
            if (bStream != null)bStream.close();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
}

private static void getMarker(int read, BufferedInputStream bStream) {

}

我想在 bufferedInputStream 中找到长 1234567890。我可以在 bufferedInputStream 中搜索长类型吗?(我不确定我是否需要“读取”作为参数。我对此表示怀疑,我可能会删除它)。如何搜索 bufferedInputStream?

4

1 回答 1

0

如果数字是 8 字节对齐且大端,则可以使用 DataInputStream。

如果不是,我建议内存映射文件并使用 ByteBuffer.order 将顺序更改为小端。这将允许您以任何您希望的方式访问该文件。

于 2013-05-31T21:41:11.703 回答