I have a method that generates 10,000 numbers and I store them in an array.
I would like these data to be written in a file of 10 lines with 1000 numbers per line.
This is what I have tried:
try {
File f = new File(System.getProperty("user.dir") + "/datos.txt");//crea el archivo txt
BufferedWriter bw;
if (f.exists()) {
bw = new BufferedWriter(new FileWriter(f));//se encargara de escribir en el txt
for (int i = 0; i < lista.getLongitud(); i++) {
bw.write((Integer) lista.obtenerNodo(i) + ",");//escribe los datos en el txt
}
bw.close();
}
} catch (Exception ex) {//si falla mandara el error generado
JOptionPane.showMessageDialog(this, "Error en IO"+ ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
}