如何用fileInputStream读取第十个byte

急用,谢谢请帮忙!

[code="java"]public class test {
public static void main(String[] args) {
byte[] tempchars = new byte[1];
File file = new File("d:/log.txt");
InputStream str = null;
try {
str = new FileInputStream(file);
try {
str.skip(9);//跳过前9个字节
int read = str.read(tempchars, 0, 1);//读取一个字节赋值给tempchars
str.close();
System.out.println("read="+read);
System.out.println("tempchars="+tempchars[0]);
} catch (IOException e) {
e.printStackTrace();
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}[/code]

楼主如果用java.io.RandomAccessFile的话可以先seek(9)然后readByte(),
java.io.FileInputStream的话,打开该输入流之后先skip(9),检查skip返回的是不是9,是的话read()

同意上面的建议:
int check = str.skip(9);
if(check == 9){
//然后处理其他
}