消息关闭
    暂无新消息!

retrue 返回null

问题作者 : 心痛2017-06-15发布
public static List<GPSData> obtainGpsdataList(String path, Context context) throws Exception {
        List<GPSData> result = new ArrayList<>();
        List<String> lath = new ArrayList<>();
        File file = new File(path);
        if (file.exists() && file.isFile()) {
            try {
                InputStream inputstream = new FileInputStream(file);
                if (inputstream != null) {
                    InputStreamReader inputstreamreader = new InputStreamReader(inputstream, "UTF-8");
                    BufferedReader bufferedreader = new BufferedReader(inputstreamreader);
                    String line;
                    while ((line = bufferedreader.readLine()) != null) {
                        lath.add(line);
                    }
                    inputstream.close();
                    inputstreamreader.close();
                    bufferedreader.close();
                }
            } catch (IOException e) {
            }
            if (lath != null && lath.size() > 0) {
                for (int i = 0; i < lath.size(); i++) {
                    String[] split = lath.get(i).split(" ");
                    if (split.length < 10) {
                        return null;
                    } else {
                        double lon = Double.parseDouble(split[0]);
                        double lat = Double.parseDouble(split[1]);
                        float speed = Float.parseFloat(split[3]);
                        float high = Float.parseFloat(split[4]);
                        float bearing = Float.parseFloat(split[2])/10;
                        float pitch = Float.parseFloat(split[5]);
                        float rool = Float.parseFloat(split[6]);
                        int bump = Integer.parseInt(split[7]);
                        float cartwheel = Float.parseFloat(split[8]);
                        byte traffic = Byte.parseByte(split[9]);
                        time+=1000;
                        result.add(new GPSData(lon, lat, speed,high, bearing, pitch,rool,bump,cartwheel, traffic,time, null));
                    }
                }
            }
            return result;
        }
        return null;
    }


result有数据,但是不执行return result 而是直接执行 return null

2个回答