我有一个包含 10 个字符串的文件 - 每个字符串在 1 行中 - 我需要运行 LCS 并获取每个比较的 LCS 和 LCS 长度,例如,字符串 1 和字符串 2、字符串 1 和字符串 3、字符串 1 和字符串4 依此类推,直到遍历每个字符串,然后递增到字符串 2 并重复此过程,直到遍历所有字符串。
我已成功将每个字符串添加到 ArrayList 以使其更容易,但现在我在尝试将所述字符串相互比较时遇到了麻烦,我想我应该使用嵌套的 for 循环,在它通过之前我不会递增整个列表,然后递增。
任何帮助表示赞赏。这是我到目前为止的代码。
public static void main(String[] args) {
List<String> Collection = new ArrayList<>();
String FirstLine = null;
int i;
File Temp1 = new File("CollectionSeqs/listSeqs-consensustest-errorhigh-l10.nsol_win.txt");
try{
InputStream fis = new FileInputStream(Temp1);
BufferedReader br = new BufferedReader(new InputStreamReader(fis));
for (String line = br.readLine(); line != null; line = br.readLine()) {
Collection.add(line);
System.out.println(line);
}
br.close();
}
catch(Exception e){
System.err.println("Error: Target File Cannot Be Read");
}