Posted: 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. |
|
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 |
|
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 |