import java.io.*; import java.util.Random; class Swipe { // This method is purely for demonstrating a use case of 'throws' specification. public static void writeBytes(FileOutputStream os, byte[] data) throws IOException { os.write(data); } public static void main(String[] args) throws IOException { FileOutputStream os = null; try { os = new FileOutputStream(args[0]); Random r = new Random(); byte[] data = new byte[Integer.parseInt(args[1])]; r.nextBytes(data); writeBytes(os, data); } catch (FileNotFoundException e) { System.out.println("Not a file!"); } finally { if (os != null) os.close(); } } }