小编use*_*293的帖子

读取单行文本文件,拆分为数组

我正在从一个看起来完全像这样的文本文件中读取一长串信息:

Sebastien 5000\\Loic 5000\\Shubhashisshh 5000\\Thibaullt 5000\\Caroo 5000\\Blabla 5000\\Okayyy 5000\\SebCed 5000\\abusee 5000\\omg 5000\\

它应该是用户名称的高分.当我打印出该行时,它看起来应该是这样,但是当我在使用后打印出数组时split("\\\\"),它看起来像这样:

[Sebastien 5000, , Loic 5000, , Shubhashisshh 5000, , Thibaullt 5000, , Caroo 5000, , Blabla 5000, , Okayyy 5000, , SebCed 5000, , abusee 5000, , omg 5000]

问题是,Array[0]是好的,但是Array[1]是空的,因为都是Array[3],Array[5]等等.

这是我的代码.它出什么问题了?

            BufferedReader in = null;
    try {
        in = new BufferedReader(new FileReader(path));
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }

    String line = null;
    try {
        line = …
Run Code Online (Sandbox Code Playgroud)

java arrays text split file

7
推荐指数
1
解决办法
1561
查看次数

标签 统计

arrays ×1

file ×1

java ×1

split ×1

text ×1