Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arrays 如何使用JFileChooser从文本文件中获取双精度数字,并将其存储在Number类型的数组(具有对象类型的数组))中?_Arrays_Object_Data Structures_Text Files - Fatal编程技术网

Arrays 如何使用JFileChooser从文本文件中获取双精度数字,并将其存储在Number类型的数组(具有对象类型的数组))中?

Arrays 如何使用JFileChooser从文本文件中获取双精度数字,并将其存储在Number类型的数组(具有对象类型的数组))中?,arrays,object,data-structures,text-files,Arrays,Object,Data Structures,Text Files,如果我有一个数字如下的文本文件: 25.1, 2.2, .02, .11, 11.5, 9.6, 等 我如何将所有这些存储在Number类型的数组中(例如,Number[]myArray)? 如何从文本文件将这些数字存储在myArray中 名为Number.txt的假设文本文件中的示例编号 .20 十一, 十三, 15.2 .02 .14 .15 .16 .78 .19 十四, 二十三 二十四 .18 public static void main(String[] args) throws I

如果我有一个数字如下的文本文件: 25.1, 2.2, .02, .11, 11.5, 9.6, 等 我如何将所有这些存储在Number类型的数组中(例如,Number[]myArray)? 如何从文本文件将这些数字存储在myArray中

名为Number.txt的假设文本文件中的示例编号

.20

十一,

十三,

15.2

.02

.14

.15

.16

.78

.19

十四,

二十三

二十四

.18

public static void main(String[] args) throws IOException {
        JFileChooser jfc = new JFileChooser(FileSystemView.getFileSystemView().getHomeDirectory());
        jfc.setDialogTitle("Coose a Directory.");
        jfc.setAcceptAllFileFilterUsed(false);
        FileNameExtensionFilter filter = new FileNameExtensionFilter("TXT Files Only", "txt");
        jfc.addChoosableFileFilter(filter);
        int returnValue = jfc.showSaveDialog(null);
        if (returnValue == JFileChooser.APPROVE_OPTION) {
            
            File selectedFile = jfc.getSelectedFile();
            //System.out.println(selectedFile.getAbsolutePath());
            String line = "";
            BufferedReader br = new BufferedReader(new FileReader(selectedFile));
                  
            while((line = br.readLine()) != null){
                /* Right Here.How do I store "selectedFile" into an array of type Number?*/
            }
        }
        else {
            System.out.println("File not located.");
        }
}//end main