我有两个带有主键的 csv,我试图将两个键合并,以便我可以将相关的 csv 与正确的键组合在一起,但是现在我只想比较一列中的内容。我的脑子有点空白,我希望通过代码你能弄清楚我前进的方向。我无法让我的数组真正接收字符串。Java.lang.arrayindexoutofboundsexception
import java.io.;
import java.util.;
public class UDC {
public void search(String [][] wat, String [][] ud){
}
public static void main (String [] args) throws IOException
{
String [] [] cols = {};
String [] [] cols1={};
int row =0;
int row1 =0;
int j = 0;
/*Scanner s = new Scanner(new File("Watford Update File.csv"));
Scanner c = new Scanner(new File("udc.csv"));
while (s.hasNextLine()){
String line = s.nextLine();
cols =line.split(",");
System.out.println(cols[0]);*/
Scanner s = new Scanner(new File("file1.csv"));
Scanner w = new Scanner (new File("file.csv"));
while (w.hasNextLine())
{
String line1 = w.nextLine();
System.out.println(cols);
//cols[row]=line1.split(",");
row ++;
if(!w.hasNextLine()){
while (s.hasNextLine()){
String line2 = s.nextLine();
//cols1[row1]=line2.split(",");
//put while loop in diffrent method but break
if(cols[j].equals(cols1[row1]))
{
j++;
row1++;
System.out.print(cols[j]);
System.out.print(" ");
System.out.print(cols1[row1]);
System.out.println();
}else{
row1++;
}
}
}
}
}
}