如果文件对象返回null
,如何捕获抛出的null?我一直在java.lang.NullPointerException
。
public static File getFile() {
String filePath = JOptionPane.showInputDialog("Enter the full path to the file you want to open");
File file = new File(filePath);
while(!file.exists()) {
filePath = JOptionPane.showInputDialog("Please enter a valid full path");
}
return file;
}
}
答案 0 :(得分:0)
关于public File(String pathname)
构造函数的javadoc:
NullPointerException - If the pathname argument is null
因此,在将filePath
传递给null
new File(String path)
不是 stdClass Object
(
[result_count] => 1
[total_count] => 1
[next_offset] => 1
[entry_list] => Array
(
[0] => stdClass Object
(
[id] => 6adfd27d-0a48-48c9-97b2-5639c6d9e697
[module_name] => Leads
[name_value_list] => stdClass Object
(
[assigned_user_name] => stdClass Object
(
[name] => assigned_user_name
[value] => Administrator
)
[modified_by_name] => stdClass Object
(
[name] => modified_by_name
[value] => Administrator
)
[created_by_name] => stdClass Object
(
[name] => created_by_name
[value] => Administrator
)
[id] => stdClass Object
(
[name] => id
[value] => 6adfd27d-0a48-48c9-97b2-5639c6d9e697
)