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中搜索long类型?(我不确定是否需要“read”作为参数。我怀疑不需要,我可能会将其删除)。如何搜索bufferedInputStream?大端字节序,8字节对齐。
我要搜索的初始标记包含值1234567890。一旦我找到该值,我想将2个字节的值放入变量中。这2个字节位于标记后11个字节处。