I'm doing a program in which I take the same value of a point in 8 different txt and I want the output to be a txt in which 1,048,576 rows x 8 columns appear, but when it comes to getting the output I the numbers come together with more than 8 columns ..
I have tried everything putting \ n inside the for loop (j ....) as it was ... could anyone tell me what error?
Is it like this because of the large amount of data?
Thank you very much
package ber.unico.com;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;
public class FiltroUnico {
public static void main(String[] args) throws IOException {
int n=1048576;
float datos[][] = new float[n][8];
Scanner sc1,sc2,sc3,sc4,sc5,sc6,sc7,sc8;
try {
sc1 = new Scanner(new File("C:\Users\jose\Desktop\f1.txt"));
sc2 = new Scanner(new File("C:\Users\jose\Desktop\f2.txt"));
sc3 = new Scanner(new File("C:\Users\jose\Desktop\f3.txt"));
sc4 = new Scanner(new File("C:\Users\jose\Desktop\f4.txt"));
sc5 = new Scanner(new File("C:\Users\jose\Desktop\f5.txt"));
sc6 = new Scanner(new File("C:\Users\jose\Desktop\f6.txt"));
sc7 = new Scanner(new File("C:\Users\jose\Desktop\f7.txt"));
sc8 = new Scanner(new File("C:\Users\jose\Desktop\f8.txt"));
FileWriter fw;
fw = new FileWriter(newFile("C:\Users\jose\Desktop\Salid.txt"));
for(int i=0;i<n;i++){
if (sc1.hasNextFloat()) {
datos[i][0] = sc1.nextFloat();
}
if (sc2.hasNextFloat()) {
datos[i][1] = sc2.nextFloat();
}
if (sc3.hasNextFloat()) {
datos[i][2] = sc3.nextFloat();
}
if (sc4.hasNextFloat()) {
datos[i][3] = sc4.nextFloat();
}
if (sc5.hasNextFloat()) {
datos[i][4] = sc5.nextFloat();
}
if (sc6.hasNextFloat()) {
datos[i][5] = sc6.nextFloat();
}
if (sc7.hasNextFloat()) {
datos[i][6] = sc7.nextFloat();
}
if (sc8.hasNextFloat()) {
datos[i][7] = sc8.nextFloat();
}
for(int j=0;j<8;j++){
System.out.print(datos[i][j] + " ");
fw.write(datos[i][j] + " ");
}
System.out.println();
}
fw.flush();
fw.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}