日期:2014-05-20  浏览次数:20640 次

scanner读取数据出错
package baset639rainforecast.data;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.InputMismatchException;
import java.util.Scanner;

/**
 *读取micaps第4类格式数据,单要素文件
 * @author lfg
 */
public class Diamond4Reader {

    private double startLon, startLat, endLon, endLat;
    private double interLon, interLat;
    private int numLon, numLat;
    private double data[][];
    private double lon[][], lat[][];
    // private Point[][] points;

    /**
     * 构造函数
     * @param fileName 文件名 
     */
    public Diamond4Reader(String fileName) throws FileNotFoundException {
        File file = new File(fileName);
        Scanner scanner = null;
        try {
            scanner = new Scanner(file);
            //跳过一些不需要的信息,如果需要,可以再分解
            for (int i = 0; i < 9; i++) {
                scanner.next();
            }
            this.interLon = scanner.nextDouble();
            this.interLat = scanner.nextDouble();
            this.startLon = scanner.nextDouble();
            this.endLon = scanner.nextDouble();
           // System.err.println("endLon = "+ endLon);
            this.startLat = scanner.nextDouble();
            this.endLat = scanner.nextDouble();
            this.numLon = scanner.nextInt();
            this.numLat = scanner.nextInt();
            data = new double[this.numLon][this.numLat];//初始化data变量
            for (int i = 0; i < 5; i++) {
                scanner.next();
            }
            while (scanner.hasNext()) {
                for (int i = 0; i < this.numLat; i++) {
                    for (int j = 0; j < this.numLon; j++) {