我有一个包含文档信息的.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)