Well I have a problem, I have 2 methods, one that counts the lines of a .txt file and another method that creates an array of the file lines so that I can print it in a JOptionpane.messagedialog
1st method
//metodo que devuelve el numero de lineas del archivo case 6
public int mostrarfarmacia(InputStream is) throws IOException{
int n=0;
InputStreamReader ir = new InputStreamReader(is);
BufferedReader bs = new BufferedReader(ir);
String linea = bs.readLine();
while(linea!=null) {
linea = bs.readLine();
n++;
}
bs.close();
return n;
}
2nd method
//metodo que imprime el archivo faramcia case 6
public void mostrarfarmacia1(InputStream is, int n) throws IOException{
int i = 0;
InputStreamReader ir = new InputStreamReader(is);
BufferedReader bs = new BufferedReader(ir);
String[] lineas = new String[n];
String linea = bs.readLine();
while(linea!=null) {
lineas[i] = linea;
linea = bs.readLine();
i++;
}
bs.close();
JOptionPane.showMessageDialog(null, lineas);
}
My problem is that when printing the array with the contents of the file, if the file is long, when printing it in the JOptionpane.showmessagedialog it prints a part and the rest prints it out of the screen, which makes it impossible to visualize it, I would like to know if there is a way to be able to visualize everything, or I would have to use other functions than the JOptionpane.showmessagedialog