Object 为什么可以';我是否在类中声明BufferedReader并在方法上使用其对象?
IDE给出的错误: 默认构造函数无法处理异常类型FileNotFoundException 由隐式构造函数抛出。方法必须定义显式 构造器 可能的副本。另请参阅。可能的副本。另见。Object 为什么可以';我是否在类中声明BufferedReader并在方法上使用其对象?,object,static,instance,bufferedreader,ioexception,Object,Static,Instance,Bufferedreader,Ioexception,IDE给出的错误: 默认构造函数无法处理异常类型FileNotFoundException 由隐式构造函数抛出。方法必须定义显式 构造器 可能的副本。另请参阅。可能的副本。另见。 public class Example { static String s; static String str; static String[] strArray; static BufferedReader br = new BufferedReader(new FileReade
public class Example {
static String s;
static String str;
static String[] strArray;
static BufferedReader br = new BufferedReader(new FileReader("C:........."));
...
}
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);
}
}