...
Code Block | ||
---|---|---|
| ||
class FileWrite { public static void main(String[] args) throws NumberFormatException, IOException { FileOutputStream out = new FileOutputStream("output"); //Perform range checking if(Integer.valueOf(args[0]) < 0 || Integer.valueOf(args[0]) > 255) { throw new ArithmeticException("Value is out of range"); } out.write(Integer.valueOf(args[0].toString())); System.out.flush(); } } |
Wiki Markup |
---|
When {{args\[0\]}} contains a value that falls outside the representable range of an {{int}}, the {{Integer.valueOf()}} method throws a {{NumberFormatException}}. |
Compliant Solution (Use writeInt()
)
...