Java Reference
In-Depth Information
// Use a DecimalFormat object to make sure 2 digits
// are used when you print the value.
DecimalFormat form = new DecimalFormat();
form.setMinimumIntegerDigits(2);
Then replace the statement that creates the output text with this statement,
which uses the DecimalFormat object:
// String text = "This is text " + i;
String text = "This is text " + form.format(i);
Finally, change the size of the read buffer:
// byte [] bytes = new byte[14];
byte [] bytes = new byte[15];
10. Let's compile this program and execute it. The output should look like this:
File exists
File exists
This is text 00
This is text 01
This is text 02
This is text 03
This is text 04
This is text 05
This is text 06
This is text 07
This is text 08
This is text 09
This is text 10
This is text 11
This is text 12
This is text 13
This is text 14
This is text 15
This is text 16
This is text 17
This is text 18
This is text 19
Notice that output is now formatted based on fixed length “rows.”
Search WWH ::




Custom Search