我的程序将文件读入字节数组,但我不知道为什么数组结果中有很多负数。我认为数组中的元素的值在 0 到 255 之间。这里的代码:
public static void main(String [] args)
{
try
{
File file = new File("C:\\1.mp3");
FileInputStream fis = new FileInputStream(file);
byte[] bytes = new byte[(int)file.length()];
fis.read(bytes);
boolean check = true;
int i = -1;
while(check)
{
i=i+1;
if(bytes[i]<0)
{
check = false;
System.out.println("There is a negative number.");
}
}
}
catch(IOException ex)
{
System.out.println(ex.getMessage());
}
}
感谢您的帮助。