警告"转换为try-with-resources" ,警告出现在此代码中的(outStream)指令下,请帮忙吗?
static void doTestByteFiles() throws IOException {
File file = new File("sample1.data");
FileOutputStream outStream = new FileOutputStream(file); //Warning!!!!
byte[] outByteArray = {10,20,30,40,50,60,70,80,(byte)'J',(byte)'a',(byte)'v',(byte)'a'};
outStream.write(outByteArray);
outStream.close();
FileInputStream inStream = new FileInputStream(file);
int fileSize = (int) file.length();
byte[] inByteArray = new byte[fileSize];
inStream.read(inByteArray);
for (int i = 0; i < fileSize; i++) {
System.out.println((char) inByteArray[i]);
}
inStream.close();
}