我正在阅读一本 Java 考试准备书。当我读到下面的例子时,我很困惑:
byte [] magicNumber = {( byte) 0xCA, (byte) 0xFE, (byte) 0xBA, (byte) 0xBE};
try (FileInputStream fis = new FileInputStream( fileName)) {
byte[] u4buffer = new byte[ 4];
if( fis.read( u4buffer) != − 1) {
if( Arrays.equals( magicNumber, u4buffer)) {
System.out.printf(" The magic number for passed file %s matches that of a .class file", fileName);
} else {
System.out.printf(" The magic number for passed file %s does not match that of a .class file", fileName);
}
}
} catch( FileNotFoundException fnfe) {
System.err.println(" file does not exist with the given file name ");
} catch( IOException ioe) {
System.err.println(" an I/ O error occurred while processing the file");
}
这是什么意思:read(u4buffer)?
最佳答案
关于java - 为什么Java的FileInputStream read()带参数,而Oracle的文档却说不带参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25329312/