public class Example {
static String s;
static String str;
static String[] strArray;
static BufferedReader br = new BufferedReader(new FileReader("C:........."));
...
}
IDE提供的错误:
默认构造函数无法处理异常类型FileNotFoundException 由隐式构造函数抛出。方法必须定义显式 构造
public static void main(String[] args) throws IOException {
method1();
}
public void method1()throws IOException {
str = br.readLine(); // I want to be able to use the br object here
// or any method as per need.
strArray = str.split("//s");
for(String s: strArray) {
Sysout.out.println(s);
}
}