@Override public void changeXmlFile(String filename) throws FileNotFoundException { File file = new File(filename); if (file.exists()) { this.modelCompletedCommand = 12; @SuppressWarnings("resource") XMLDecoder decoder = new XMLDecoder(new BufferedInputStream(new FileInputStream(filename))); p.setDefAlgorithm((String) decoder.readObject()); p.setDefSolver((String) decoder.readObject()); p.setNumofThreads((int) decoder.readObject()); p.setUI((String) decoder.readObject()); Object[] dataSet = new Object[4]; dataSet[0] = p.getDefAlgorithm(); dataSet[1] = p.getDefSolver(); dataSet[2] = p.getNumofThreads(); dataSet[3] = p.getUI(); setChanged(); this.setData(dataSet); notifyObservers(); } else errorNoticeToController("Xml file Error"); }
@SuppressWarnings("unchecked") public MyModel(Properties p) throws Exception { super(); this.p = p; this.c = Executors.newFixedThreadPool(p.getNumofThreads()); File sol = new File("solutionMap.txt"); if (sol.exists()) { ObjectInputStream solLoader; try { solLoader = new ObjectInputStream( new GZIPInputStream(new FileInputStream(new File("solutionMap.txt")))); solutionMap = (HashMap<Maze3d, Solution<Position>>) solLoader.readObject(); solLoader.close(); this.p = read("Properties.xml"); } catch (FileNotFoundException e) { errorNoticeToController("Error: problem with solution file"); } catch (IOException e) { errorNoticeToController("Error: IO exeption"); } catch (ClassNotFoundException e) { errorNoticeToController("Error: problem with class"); } } }