Java read file and store text in an array

前端 未结 7 1824
心在旅途
心在旅途 2020-11-30 06:25

I know how to read a file with Java using Scanner and File IOException, but the only thing I don\'t know is how to store the text in the files as a

相关标签:
7条回答
  • 2020-11-30 07:03
    while(inFile1.hasNext()){
    
        token1 = inFile1.nextLine();
    
        // put each value into an array with String#split();
        String[] numStrings = line.split(", ");
    
        // parse number string into doubles 
        double[] nums = new double[numString.length];
    
        for (int i = 0; i < nums.length; i++){
            nums[i] = Double.parseDouble(numStrings[i]);
        }
    
    }
    
    0 讨论(0)
提交回复
热议问题