Warning

 

Close
Confirm Action

Are you sure you wish to do this?

Cancel Confirm
AR15.COM
3/18/2008 7:40:15 PM EDT
I need some help formatting my output.

I need to make a table, but I can't seem to get printf to work correctly (I've never used it before).

If somebody could take a look at my code, that'd be awesome.
3/19/2008 8:50:48 AM EDT
[#1]
Maybe this will help a bit.  I always use a System.out.println(""); type output when I'm just printing to the terminal, not sure what you're trying to do as far as the output.  But maybe Formatter can help you.

java.sun.com/j2se/1.5.0/docs/api/java/util/Formatter.html
3/19/2008 11:08:07 AM EDT
[#2]
I usually just use println as well, but this code needed the output to be formatted in a table.

It took me a while, but I got it all figured out.

The project asked for a master boot record to be parsed, then the program would output the type, size, whether it's bootable, and the starting LBA of each partition.

The basic printf code is:
System.out.printf("%10s", args);

With 10 being the space given for that column.  Args would be whatever you want printed, such as "NTFS".

Anyway, it was a project for my digital forensics class.
3/20/2008 10:05:49 AM EDT
[#3]

Quoted:
I usually just use println as well, but this code needed the output to be formatted in a table.

It took me a while, but I got it all figured out.

The project asked for a master boot record to be parsed, then the program would output the type, size, whether it's bootable, and the starting LBA of each partition.

The basic printf code is:
System.out.printf("%10s", args);

With 10 being the space given for that column.  Args would be whatever you want printed, such as "NTFS".

Anyway, it was a project for my digital forensics class.


Ahhh, that sounds fun