编辑:已解决我已将变量声明超出范围。
所以我在尝试编译时遇到错误:
cannot find symbol
symbol : variable bos
location: class steganography
byte[] bytes = bos.toByteArray();
违规代码:
//We'll use this to read the file in
FileInputStream fis = new FileInputStream(file);
//We'll use this to push the file out
ByteArrayOutputStream bos = new ByteArrayOutputStream();
try {
for (int readNum; (readNum = fis.read(buf)) != -1;) {
bos.write(buf, 0, readNum);
//no doubt here is 0
/*Writes len bytes from the specified byte array starting at offset off to this byte array output stream.*/
System.out.println("read " + readNum + " bytes,");
}
} catch (IOException ex) {
System.out.println(ex);
//Logger.getLogger(ConvertImage.class.getName()).log(Level.SEVERE, null, ex);
}
很抱歉没有提供更多信息我是java n00b。
答案 0 :(得分:1)
不太确定这是你提出的“违规代码”。你能告诉我们这是什么:
byte[] bytes = bos.toByteArray();
答案 1 :(得分:1)
如果可能的话,很高兴看到完整的问题及其解决方案!这使得这个问题和答案对后来的观众更有用:)
看起来您可能已将变量bos
声明为超出范围,因此编译器无法识别该特定类型及其方法。这听起来像你做的那样吗?