package class7_2_LoadingBinaryData_inClass;// Dr. Yoder. MSOE. 26 January 2017 import java.io.*; import java.nio.file.Paths; import java.util.InputMismatchException; public class Circle { private int centerY; private int centerX; private int radius; public Circle(int centerY, int centerX, int radius) { this.centerY = centerY; this.centerX = centerX; this.radius = radius; } public Circle(String filename) throws ShapeException { try { FileInputStream fileInStream = new FileInputStream(Paths.get(filename).toFile()); DataInputStream dataIn = new DataInputStream(fileInStream); centerX = dataIn.readShort(); centerY = dataIn.readShort(); radius = dataIn.readShort(); fileInStream.close(); } catch (EOFException e) { String message = "We reached the end of the file before reading in the whole circle object."; System.out.println(message); throw new ShapeException(message,e); } catch (FileNotFoundException e) { String message = "Could not find the file: "+filename; System.out.println(message); throw new ShapeException(message,e); } catch (IOException e) { String message = "An unknown file IO exception occured. "+e.getMessage(); System.out.println(message); throw new ShapeException(message,e); } } @Override public String toString() { return "Circle at ("+centerX+", "+centerY+") with radius "+radius; } }