I have hundreds of text files with data sorted in 3 columns and an unspecified number of rows. The number of columns can increase in the future, but will always be equal for all files. I want to combine these data into a single file with all the columns put next to each other. For example:

File one:
Aa; Bb; Cc
34; 65; 78
23; 88; 68
34; 87; 12

File two:
Aa; Bb; Cc
1; 2; 3
4; 5; 6

Should become one file:
Aa; Bb; Cc; Aa; Bb; Cc
34; 65; 78; 1; 2; 3
23; 88; 68; 4; 5; 6
34; 87; 12;

I took a basic java programming course in university but didn’t program anything in years, so I’m a bit rusty. Can anyone propose a work flow to get this done, so I can familiarize myself with all the needed classes. Also please point out pitfalls if any.
I think it would be nice to show the user the resulting table in a JTable before writing the output file. So I think this requires storing the data in a two-dimensional Object array?

If its txt file, one of the way is to create a third file with both the data

FileInputStream fi = new FileInputStream(File1);
BufferedReader br = new BufferedReader(new InputStreamReader(fi));
FileInputStream fi2 = new FileInputStream(File2);
BufferedReader br2 = new BufferedReader(new InputStreamReader(fi2));
String strLine;
while ((strLine = br.readLine()) != null) {
String strLine2 = br2.readLine();
if(strLine2!=null){
//PrintStream Both Data to new File
}
}
br2.close();
br.close();

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.