java逐行读取文件(读取文件每一行、按行读取文件)附带详细代码

 更新时间:2023年09月26日 09:19:43   作者:AKA石头  
这篇文章主要给大家介绍了关于java逐行读取文件(读取文件每一行、按行读取文件)的相关资料,读取文件是我们在日常工作中经常遇到的一个需求,文中通过代码介绍的非常详细,需要的朋友可以参考下

BufferedReader

最快的读取每一行

@Test
    public void bufferReaderTest() {
        try (BufferedReader bufferedReader = new BufferedReader(new FileReader("D:\\aa.txt"))) {
            String line;
            while ((line = bufferedReader.readLine())  != null) {
                // 处理每一行数据 .....
            }
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
    }

Scanner

相比较Scanner慢一点

 	@Test
    public void scannerTest() {
        try (Scanner scanner = new Scanner(new File("D:\\aa.txt"))) {
            while (scanner.hasNextLine()) {
                // 处理每一行数据 .....
                String line = scanner.nextLine();
            }
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
    }

RandomAccessFile

行数达到一定规模,使用此方法读取会非常慢

@Test
    public void randomAccessFileTest() {
        try (RandomAccessFile accessFile = new RandomAccessFile("D:\\aa.txt", "r")) {
            String line;
            while ((line = accessFile.readLine()) != null) {
                // 处理每一行数据 .....
            }
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
    }

Files

一次把所有数据都读到内存中,当文件非常大时,会消耗掉内存资源导致程序崩掉,文件规模小推荐使用

@Test
    public void filesTest() {
        try {
            List<String> lines = Files.readAllLines(Paths.get("D:\\aa.txt"));
            lines.forEach(line -> {
                // 处理每一行数据 .....
            });
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
    }

示例代码

统计每一行日志ip出现的次数

package io;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;  
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.RandomAccessFile;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
/**
 * @Author: Lisy
 * @Date: 2023/04/17/9:51
 * @Description: 读取文件中每一行的数据
 */
@Slf4j
public class ReadLineTest {
    private final String FILE_NAME = "D:\\aa.txt";
    private Map<String, Integer> StringMap = new HashMap<>();
     @Test
    public void bufferReaderTest() {
        try (BufferedReader bufferedReader = new BufferedReader(new FileReader("D:\\aa.txt"))) {
            String line;
            while ((line = bufferedReader.readLine())  != null) {
                // 处理每一行数据 .....
                processLines(line);
            }
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
        print("BufferedReader");
    }
    @Test
    public void scannerTest() {
        try (Scanner scanner = new Scanner(new File(FILE_NAME))) {
            while (scanner.hasNextLine()) {
                // 处理每一行数据 .....
                String line = scanner.nextLine();
                processLines(line);
            }
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
        print("Scanner");
    }
    @Test
    public void randomAccessFileTest() {
        try (RandomAccessFile accessFile = new RandomAccessFile(FILE_NAME, "r")) {
            String line;
            while ((line = accessFile.readLine()) != null) {
                // 处理每一行数据 .....
                processLines(line);
            }
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
        print("RandomAccessFile");
    }
    @Test
    public void filesTest() {
        try {
            List<String> lines = Files.readAllLines(Paths.get(FILE_NAME));
//            lines.forEach(line -> {
//                // 处理每一行数据 .....
//                processLines(line);
//            });
            // 处理每一行数据 .....,方法引用更简洁
            lines.forEach(this::processLines);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
        print("Files.readAllLines");
    }
    private void print(String name) {
        log.info("************* {} *******************", name);
        StringMap.forEach((k, v) -> {
            if (v != 1) {
               log.info("ip: {} count: {}", k, v);
            }
        });
        StringMap.clear();
    }
    private void processLines(String line) {
        String[] subLine = line.split(" ");
        String ip = subLine[subLine.length - 1];
        if (StringMap.containsKey(ip)) {
            Integer integer = StringMap.get(ip);
            StringMap.put(ip, integer + 1);
        } else {
            StringMap.put(ip, 1);
        }
    }
}

测试数据

2023-04-14 09:50:51,211 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.172
2023-04-14 09:50:51,211 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.64
2023-04-14 09:50:51,212 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.64
2023-04-14 09:50:51,212 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.69
2023-04-14 09:50:51,212 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.159
2023-04-14 09:50:51,212 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.161
2023-04-14 09:50:51,213 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.93.68
2023-04-14 09:50:51,213 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.186
2023-04-14 09:50:51,213 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.93.74
2023-04-14 09:50:51,213 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.64
2023-04-14 09:50:51,214 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.64
2023-04-14 09:50:51,214 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.95
2023-04-14 09:50:51,214 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.87
2023-04-14 09:50:51,214 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.93.127
2023-04-14 09:50:51,215 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.91
2023-04-14 09:50:51,215 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.93.115
2023-04-14 09:50:51,216 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.198
2023-04-14 09:50:51,216 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.105
2023-04-14 09:50:51,216 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.60
2023-04-14 09:50:51,216 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.60
2023-04-14 09:50:51,217 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.77
2023-04-14 09:50:51,217 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.93.125
2023-04-14 09:50:51,217 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.60
2023-04-14 09:50:51,217 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.173
2023-04-14 09:50:51,218 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.129
2023-04-14 09:50:51,218 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.208
2023-04-14 09:50:51,218 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.211
2023-04-14 09:50:51,218 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.63
2023-04-14 09:50:51,219 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.170
2023-04-14 09:50:51,219 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.195
2023-04-14 09:50:51,219 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.181
2023-04-14 09:50:51,219 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.180
2023-04-14 09:50:51,220 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.61
2023-04-14 09:50:51,220 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.201
2023-04-14 09:50:51,220 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.90
2023-04-14 09:50:51,220 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.93.26
2023-04-14 09:50:51,221 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.200
2023-04-14 09:50:51,221 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.126
2023-04-14 09:50:51,221 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.192
2023-04-14 09:50:51,221 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.96
2023-04-14 09:50:51,221 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.93.59
2023-04-14 09:50:51,222 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.93.50
2023-04-14 09:50:51,222 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.64
2023-04-14 09:50:51,222 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.64
2023-04-14 09:50:51,223 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.125
2023-04-14 09:50:51,223 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.82
2023-04-14 09:50:51,223 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.150
2023-04-14 09:50:51,223 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.209
2023-04-14 09:50:51,224 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.170
2023-04-14 09:50:51,224 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.93.51
2023-04-14 09:50:51,224 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.152
2023-04-14 09:50:51,224 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.93.21
2023-04-14 09:50:51,224 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.71
2023-04-14 09:50:51,225 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.88
2023-04-14 09:50:51,225 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.188
2023-04-14 09:50:51,225 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.187
2023-04-14 09:50:51,225 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.81
2023-04-14 09:50:51,226 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.155
2023-04-14 09:50:51,226 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.93.57
2023-04-14 09:50:51,226 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.148
2023-04-14 09:50:51,226 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.156
2023-04-14 09:50:51,226 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.154
2023-04-14 09:50:51,227 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.146
2023-04-14 09:50:51,227 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.160
2023-04-14 09:50:51,227 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.60
2023-04-14 09:50:51,227 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.93.123
2023-04-14 09:50:51,227 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.60
2023-04-14 09:50:51,228 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.184
2023-04-14 09:50:51,228 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.151
2023-04-14 09:50:51,228 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.182
2023-04-14 09:50:51,229 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.93.113
2023-04-14 09:50:51,229 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.89
2023-04-14 09:50:51,229 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.191
2023-04-14 09:50:51,229 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.205
2023-04-14 09:50:51,229 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.60
2023-04-14 09:50:51,230 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.74
2023-04-14 09:50:51,230 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.127
2023-04-14 09:50:51,230 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.157
2023-04-14 09:50:51,230 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.165
2023-04-14 09:50:51,231 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.93.122
2023-04-14 09:50:51,231 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.162
2023-04-14 09:50:51,231 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.183
2023-04-14 09:50:51,231 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.202
2023-04-14 09:50:51,232 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.166
2023-04-14 09:50:51,232 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.64
2023-04-14 09:50:51,234 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.210
2023-04-14 09:50:51,234 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.93
2023-04-14 09:50:51,234 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.171
2023-04-14 09:50:51,234 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.204
2023-04-14 09:50:51,235 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.207
2023-04-14 09:50:51,235 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.199
2023-04-14 09:50:51,235 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.124
2023-04-14 09:50:51,235 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.64
2023-04-14 09:50:51,236 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.123
2023-04-14 09:50:51,236 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.107
2023-04-14 09:50:51,236 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.169
2023-04-14 09:50:51,236 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.76
2023-04-14 09:50:51,236 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.94
2023-04-14 09:50:51,237 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.176
2023-04-14 09:50:51,237 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.93.24
2023-04-14 09:50:51,237 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.177
2023-04-14 09:50:51,237 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.93.23
2023-04-14 09:50:51,238 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.149
2023-04-14 09:50:51,238 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.75
2023-04-14 09:50:51,238 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.62
2023-04-14 09:50:51,239 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.64
2023-04-14 09:50:51,239 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.64
2023-04-14 09:50:51,239 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.70
2023-04-14 09:50:51,239 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.197
2023-04-14 09:50:51,239 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.60
2023-04-14 09:50:51,240 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.174
2023-04-14 09:50:51,240 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.93.114
2023-04-14 09:50:51,240 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.93.121
2023-04-14 09:50:51,240 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.189
2023-04-14 09:50:51,241 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.106
2023-04-14 09:50:51,241 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.93.126
2023-04-14 09:50:51,241 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.153
2023-04-14 09:50:51,241 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.167
2023-04-14 09:50:51,242 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.60
2023-04-14 09:50:51,242 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.190
2023-04-14 09:50:51,242 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.175
2023-04-14 09:50:51,242 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.206
2023-04-14 09:50:51,243 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.108
2023-04-14 09:50:51,243 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.93.112
2023-04-14 09:50:51,243 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.194
2023-04-14 09:50:51,243 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.93.25
2023-04-14 09:50:51,244 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.185
2023-04-14 09:50:51,244 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.179
2023-04-14 09:50:51,244 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.60
2023-04-14 09:50:51,244 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.64
2023-04-14 09:50:51,245 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.93.117
2023-04-14 09:50:51,245 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.64
2023-04-14 09:50:51,245 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.193
2023-04-14 09:50:51,245 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.92
2023-04-14 09:50:51,245 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.147
2023-04-14 09:50:51,246 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.93.116
2023-04-14 09:50:51,246 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.101
2023-04-14 09:50:51,246 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.196
2023-04-14 09:50:51,246 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.203
2023-04-14 09:50:51,246 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.86
2023-04-14 09:50:51,247 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.163
2023-04-14 09:50:51,247 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.178
2023-04-14 09:50:51,247 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.93.67
2023-04-14 09:50:51,247 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.97
2023-04-14 09:50:51,248 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.145
2023-04-14 09:50:51,248 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.158
2023-04-14 09:50:51,248 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.93.124
2023-04-14 09:50:51,248 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.93.111
2023-04-14 09:50:51,248 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.93.99
2023-04-14 09:50:51,249 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.106.128
2023-04-14 09:50:51,249 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.168
2023-04-14 09:50:51,249 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.93.128
2023-04-14 09:50:51,249 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 172.31.93.22
2023-04-14 09:50:51,252 INFO  [SpringContextShutdownHook] c.i.w.i.WebSocketServiceImpl.onClosing(496) : connection close 192.168.8.164

总结

到此这篇关于java逐行读取文件(读取文件每一行、按行读取文件)的文章就介绍到这了,更多相关java逐行读取文件内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

相关文章

  • Spring项目中swagger用法与swagger-ui使用

    Spring项目中swagger用法与swagger-ui使用

    这篇文章主要介绍了Spring项目中swagger用法与swagger-ui使用,通过图文并茂的形式给大家介绍了编写springboot项目的方法及导入spring-fox依赖的代码详解,需要的朋友可以参考下
    2021-05-05
  • SpringBoot中的@Inherited注解详解

    SpringBoot中的@Inherited注解详解

    这篇文章主要介绍了SpringBoot中的@Inherited注解详解,@Inherited是一个标识,用来修饰注解,如果一个类用上了@Inherited修饰的注解,那么其子类也会继承这个注解,需要的朋友可以参考下
    2023-08-08
  • java识别一篇文章中某单词出现个数的方法

    java识别一篇文章中某单词出现个数的方法

    这篇文章主要介绍了java识别一篇文章中某单词出现个数的方法,涉及java字符解析操作的相关技巧,具有一定参考借鉴价值,需要的朋友可以参考下
    2015-10-10
  • 使用@Validated和@Valid 解决list校验的问题

    使用@Validated和@Valid 解决list校验的问题

    这篇文章主要介绍了使用@Validated和@Valid 解决list校验的问题,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教
    2021-10-10
  • Java实现基于token认证的方法示例

    Java实现基于token认证的方法示例

    这篇文章主要介绍了Java实现基于token认证的方法示例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2019-08-08
  • 深入了解Java中的类加载机制

    深入了解Java中的类加载机制

    通常,在关于Java的类加载部分会遇到以上疑问,本文将对类加载重要部分做详细介绍,包括重要的基础概念和应用场景,在编写过程中也帮助作者重新熟悉并加固了知识点,希望在看完后对大家能有所帮助
    2022-11-11
  • 实例详解MyBatis-plus自动填充功能

    实例详解MyBatis-plus自动填充功能

    每次对数据进行新增、删除、修改时都需要对这些字段进行设置,虽然新增时间和修改时间可以使用数据库的时间,但是新增人和修改人就不能使用这样的功能,下面小编给大家介绍下MyBatis-plus自动填充功能的实例代码,感兴趣的朋友一起看看吧
    2022-01-01
  • idea直接修改新的git地址的方法(图文)

    idea直接修改新的git地址的方法(图文)

    这篇文章主要介绍了idea直接修改新的git地址的方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2020-07-07
  • SpringBoot日志进阶实战之Logback配置经验和方法

    SpringBoot日志进阶实战之Logback配置经验和方法

    本文给大家介绍在SpringBoot中使用Logback配置日志的经验和方法,并提供了详细的代码示例和解释,包括:滚动文件、异步日志记录、动态指定属性、日志级别、配置文件等常用功能,覆盖日常Logback配置开发90%的知识点,感兴趣的朋友跟随小编一起看看吧
    2023-06-06
  • Java多线程状态及方法实例解析

    Java多线程状态及方法实例解析

    这篇文章主要介绍了Java多线程状态及方法实例解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
    2020-02-02

最新评论