当我运行这个程序时,我得到" IOException:Stream Closed".该文本包含许多行数据.程序应读取每一行,执行必要的功能并将输出写入新文件.我很困惑哪个作家应该先关闭哪里.
import java.net.*;
import java.io.*;
public class URLReader {
public static void main(String[] args) throws Exception {
BufferedReader br = null;
try {
// change this value
FileInputStream fis = new FileInputStream("C:\\Users\\Rao\\Desktop\\test.txt");
br = new BufferedReader(new InputStreamReader(fis, "UTF-8"));
String sCurrentLine;
while ((sCurrentLine = br.readLine()) != null) {
processLine(sCurrentLine); //error
}
} finally {
if (br != null)
br.close();
}
}
public static void processLine(String line) throws IOException {
String prename = line.substring(22);
int siz= prename.indexOf(":"); …Run Code Online (Sandbox Code Playgroud)