Java BufferedReader Read loadLastExpInfo(String lastExpFileName)

Here you can find the source of loadLastExpInfo(String lastExpFileName)

Description

load Last Exp Info

License

Open Source License

Declaration

public static int[] loadLastExpInfo(String lastExpFileName)
            throws IOException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

public class Main {
    public static int[] loadLastExpInfo(String lastExpFileName)
            throws IOException {
        int num_user = 0;
        int type_spd = 0;
        int exp_id = 0;
        String line;/*from  w w w  . j a  va  2s .c  o m*/
        File lastExpFile = new File(lastExpFileName);
        FileReader expFileReader = new FileReader(lastExpFile);
        BufferedReader expBufferedReader = new BufferedReader(expFileReader);

        try {
            while ((line = expBufferedReader.readLine()) != null) {
                String[] lines = line.split(" ");
                if (lines.length >= 2) {
                    if (lines[0].toUpperCase().equals("NUM_USER") == true) {
                        num_user = Integer.parseInt(lines[1]);
                    }
                    if (lines[0].toUpperCase().equals("TYPE_SPD") == true) {
                        type_spd = Integer.parseInt(lines[1]);
                    }
                    if (lines[0].toUpperCase().equals("EXP_ID") == true) {
                        exp_id = Integer.parseInt(lines[1]);
                    }
                }

            }
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        expBufferedReader.close();
        int[] res = new int[3];
        res[0] = num_user;
        res[1] = type_spd;
        res[2] = exp_id;
        return res;
    }
}

Related

  1. loadIntegersFromFile(String filename)
  2. loadIntoString(InputStream is)
  3. loadJCC()
  4. loadJson(String path)
  5. loadKey(String filename)
  6. loadLine(InputStream load)
  7. loadLineByLineAndTrim(String file_path)
  8. loadLines(InputStream in, List lines)
  9. loadLines(String file)