小编kao*_*der的帖子

使用Java将.txt文件转换为数组

我有一个包含文档信息的.txt文件(适用于1400个文档).每个文档都有ID,标题,作者,区域和摘要.示例如下所示:

.I 1
.T
experimental investigation of the aerodynamics of a
wing in a slipstream .
.A
brenckman,m.
.B
j. ae. scs. 25, 1958, 324.
.W
experimental investigation of the aerodynamics of a
wing in a slipstream .
  [...]
the specific configuration of the experiment .
Run Code Online (Sandbox Code Playgroud)

我想将其中的每一个放入专用于每个类别的5个阵列中.我在将标题和摘要插入单个数组位置时遇到问题,有人能告诉我这段代码有什么问题吗?我想要做的是在读取".T"后将文本行插入位置x并在找到".A"时停止,当它发生时,将位置增加1以使其填充下一个位置

try{
    collection = new File (File location);
    fr = new FileReader (collection);
    br = new BufferedReader(fr);
    String numDoc = " ";
    int pos = 0;
    while((numDoc=br.readLine())!=null){
        if(numDoc.contains(".T")){
            while((numDoc=br.readLine())!= null && !numDoc.contains(".A")){
                Title[pos] = …
Run Code Online (Sandbox Code Playgroud)

java arrays

9
推荐指数
2
解决办法
205
查看次数

Python:检查String上的唯一字符

我要求用户输入关键字,然后删除任何重复的字符.

例:

输入:气球

输出:balon

我试过这个解决方案:字符串中所有唯一字符的列表?但它将其标记为语法错误.

有任何想法吗?

python string character unique

0
推荐指数
1
解决办法
5407
查看次数

标签 统计

arrays ×1

character ×1

java ×1

python ×1

string ×1

unique ×1