Write txt file with line break

0

I try to write a txt file, however the document writes it without line breaks.

This is the method which receives a data matrix:

private void guardarArchivo(ArrayList<String[]> matriz) {
        String[] fila = null;
        String linea;
        try {
            String nombre = "";
            JFileChooser file = new JFileChooser();
            file.showSaveDialog(this);
            File guarda = file.getSelectedFile();
            FileWriter save = new FileWriter(guarda + ".txt");
            if (guarda != null) {
                for (int i = 0; i < matriz.size(); i++) {
                    fila = matriz.get(i);
                    linea = "";
                    for (int j = 0; j < fila.length; j++) {
                        if (j == 9) {
                            linea += right(linea.concat(" " + fila[j] + "|"), 8);
                        } else {
                            linea = linea.concat(fila[j] + "|");
                        }
                    }
                    save.write(linea);                   
                }
                save.close();
                JOptionPane.showMessageDialog(null, "El archivo se a guardado Exitosamente", "Información", JOptionPane.INFORMATION_MESSAGE);
            }
        } catch (IOException ex) {
            JOptionPane.showMessageDialog(null, "Su archivo no se ha guardado", "Advertencia", JOptionPane.WARNING_MESSAGE);
        }
    }
    
asked by Summer 10.08.2018 в 16:39
source

1 answer

-2

Try typing it in HTML tags before printing it on the screen, you can use a simple paragraph for it.

<p>texto...</p> and give line breaks with <br>

    
answered by 10.08.2018 в 16:57