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
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。