I am producing a report showing what values have been updated/rejected and batch totals for end user. My problem(s) are that I am unsure of how to get the data formatted and presentable for the users!. As you can see from the example, it looks pretty naff, anyway that I can format it! to left align the string values?. I am new to Java, but have basic understanding of what I am doing. Help Example of the problem : Date Account Amount Receipt No. 23/07/01 123456 1.00 1 23/07/01 123456 10.00 2 23/07/01 123456 100.00 3 23/07/01 123456 1000.00 4
The quickest and easiest thing to do would be to use tabs (put a /t in the string where you want one), as long as you don't mind the somewhat large gaps it may leave. Otherwise, depending on how your code is, and assuming that the $ amount is the only thing that will change in length (besides the last collumn), you could make that a String before displaying it, get it's length, and then pad spaces based on that.
richard, robinson
Greenhorn
Joined: Jul 30, 2001
Posts: 3
posted
0
I will try that, I am used to other languages where you can format output lines somewhat easier!. pity there is no facility to left align strings/force strings to be fixed length, would be easier. Thankyou
So just create a method that takes a String, length and justify (right or left) and adds spaces where you want. Use a fixed width font for your display and you've got it. For numbers use NumberFormat. [This message has been edited by Paul Stevens (edited July 30, 2001).]
richard, robinson
Greenhorn
Joined: Jul 30, 2001
Posts: 3
posted
0
Yes I have managed to work it out with the help of BB members, Thankyou. My Code !!! // Format transaction count for report from Data File tempInt = Integer.valueOf(line.substring(1,9)); noofTransactions = tempInt.intValue(); tempString2 = String.valueOf(noofTransactions); theLength = ( 5 - tempString2.length()); for (int i =0; i < theLength; i ++) { tempString2 = " " + tempString2; }