美文网首页
2019-12-26

2019-12-26

作者: RGiskard | 来源:发表于2019-12-26 13:00 被阅读0次
public class Input {
    public ArrayList<Integer> inputA = new ArrayList<Integer>();
    public int Lsize;
    public int Ltype;
    public int HaveHead;

    /**
     *
     * @param filepath 文件目录
     * @throws IOException
     */
    public void readFile(String filepath) throws IOException{
        String inString = InputCmd.read(filepath);
        String cP = "features:(\\d+)\\s+(\\d+)\\s+(\\d+)\\s+(\\d+)";
        Pattern cPattern = Pattern.compile(cP);
        String dataP = "elements:\\d+(\\s+\\d+)*";
        Pattern dataPattern = Pattern.compile(dataP);
        Matcher cM = cPattern.matcher(inString);
        Matcher dM = dataPattern.matcher(inString);

        int len;
        if (cM.find()){
            this.Ltype = Integer.parseInt(cM.group(1));
            this.HaveHead = Integer.parseInt(cM.group(2));
            this.Lsize = Integer.parseInt(cM.group(3));
            len = Integer.parseInt(cM.group(4));
        }

        if (dM.find()){
            String eP = "(\\d+)";
            Pattern elePattern = Pattern.compile(eP);
            Matcher eleM = elePattern.matcher(dM.group(0));
            while(eleM.find()){
                int ele = Integer.parseInt(eleM.group(0));
                inputA.add(ele);
            }
        }
    }
}

相关文章

网友评论

      本文标题:2019-12-26

      本文链接:https://www.haomeiwen.com/subject/qwbkoctx.html