小编Ser*_*ani的帖子

如何从java中的Text文件中跳过某些行?

我目前正在学习Java,我遇到了这个问题,我想加载一个包含大量行的文件(我逐行读取文件),我想要做的就是跳过某些行(伪代码) ).

the line thats starts with (specific word such as "ABC")
Run Code Online (Sandbox Code Playgroud)

我试过用

if(line.startwith("abc"))
Run Code Online (Sandbox Code Playgroud)

但那没用.我不确定我做错了,这就是为什么我在这里寻求帮助,在加载功能的一部分下面:

public String loadfile(.........){

//here goes the variables 

try {

        File data= new File(dataFile);
        if (data.exists()) {
            br = new BufferedReader(new FileReader(dataFile));
            while ((thisLine = br.readLine()) != null) {                        
                if (thisLine.length() > 0) {
                    tmpLine = thisLine.toString();
                    tmpLine2 = tmpLine.split(......);
                    [...]
Run Code Online (Sandbox Code Playgroud)

java io out-of-memory

13
推荐指数
1
解决办法
1万
查看次数

标签 统计

io ×1

java ×1

out-of-memory ×1