¿Es posible automatizar saltos de línea con System.out.println()?

I am running a java program from the command line that prints a relatively long string retrieved from a file. Though the string is printed accurately (I am using System.out.println(string)), the line breaks are consistent with the size of my terminal window, which results in words being cut off in the middle and then continued on the next line. Is there a way to change the system print settings so that the string will still fit inside the window but breaks will only occur where there is white space or a hyphenation? Or is the only way to do this to build a simple GUI and use HTML? Thanks!

preguntado el 29 de junio de 12 a las 19:06

Unless you have line breaks in the middle of words in your input text file, there shouldn't be line breaks there when you print. I think the text is being broken simply because it is reaching the side of the terminal and word-wrapping. -

It is worth noting that your terminal is not using "line-breaks"; if you copied the content into your clipboard and pasted it into a text editor, there would be no line breaks. What is actually happening is word-wrap because the terminal does not support sideways scrolling, at least not with the default settings. -

@MohammadAdil I am using linux. -

0 Respuestas

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.