• Post Reply Bookmark Topic Watch Topic
  • New Topic

Printing string to same line  RSS feed

 
Nikolas Bernadel
Greenhorn
Posts: 10
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greetings,

I'm currently utilizing a utility class that outputs columns of Strings. The problem I'm having is that the output begins on each line rather than the same line, so columns look a little weird. According to the example given, this should work by simply printing the String. I'm using a simple PrintStream, so I'm not sure why this is happening.

Just to be clear, here's out the output should look like:

But when I print, each String starts on a new line like so:

Any suggestions?
 
Anayonkar Shivalkar
Bartender
Posts: 1558
5
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nikolas,

Welcome to CodeRanch!

I'm not familiar with the utility class you've provided, however, it seems that it provides some methods to easily print output in column format.

Could you please share the code you've written (i.e. the code in which you are invoking methods of MultiColumnPrinter)? So that we could be in better position to understand the problem and offer suggestions/solutions.
 
Nikolas Bernadel
Greenhorn
Posts: 10
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anayonkar Shivalkar wrote:Hi Nikolas,

Welcome to CodeRanch!

I'm not familiar with the utility class you've provided, however, it seems that it provides some methods to easily print output in column format.

Could you please share the code you've written (i.e. the code in which you are invoking methods of MultiColumnPrinter)? So that we could be in better position to understand the problem and offer suggestions/solutions.

Sure! Below is the current child class for the utility class:

And here's the code that adds the column names and rows:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!