日期:2014-05-20 浏览次数:21003 次
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package javaapplication10; import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.logging.Level; import java.util.logging.Logger; /** * * @author Administrator */ public class JavaApplication10 { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here String row; FileReader read; try { read = new FileReader("D:/data.txt"); BufferedReader br = new BufferedReader(read); try { while ((row = br.readLine()) != null) { String str1[] = row.split(" "); // for (String stemp : str1) { // double h = Double.parseDouble(stemp); // } } } catch (IOException ex) { Logger.getLogger(JavaApplication10.class.getName()).log(Level.SEVERE, null, ex); } } catch (FileNotFoundException ex) { Logger.getLogger(JavaApplication10.class.getName()).log(Level.SEVERE, null, ex); } } }
for (String stemp : str1) { if (stemp.equals("")) { continue; } double h = Double.parseDouble(stemp); System.out.println(h); }
------解决方案--------------------
for (int i = 0; i < 3; i++)