public WFile readFile(String strPath) { File objFile = new File(strPath); HashMap hmConts = new HashMap(); setHM(strPath, hmConts); return new WFile(objFile.lastModified(), hmConts); }
/** * Read position and size of the login box from a given abstract path. * * @param abstractPath The path to the file. */ public void readPersistence(String abstractPath) { String filepath = FileUtil.openPath(abstractPath); if (filepath != null) { BufferedReader in; String line; try { File file = new File(filepath); in = new BufferedReader(new FileReader(file)); // File must start with 'Login Panel' if ((line = in.readLine()) != null) { if (!line.startsWith("Login Panel")) { Messages.postWarning("The " + filepath + " file is " + "corrupted and being removed"); // Remove the corrupted file. file.delete(); // Set the size and position to the full vnmrj frame setDefaultSizePosition(); return; } } String h = null, w = null, x = null, y = null; int xi, yi; if (in.ready()) h = in.readLine().trim(); if (in.ready()) w = in.readLine().trim(); if (in.ready()) x = in.readLine().trim(); if (in.ready()) y = in.readLine().trim(); in.close(); // Save width and height for later use also height = Integer.decode(h).intValue(); width = Integer.decode(w).intValue(); xi = Integer.decode(x).intValue(); yi = Integer.decode(y).intValue(); // Save point for later use also position = new Point(xi, yi); // Set them setSize(width, height); setLocation(position); // If we got what we need and set the size and position, // just return now. return; } // If an exception, continue below catch (Exception e) { } } // No file or an excpetion happened, set default size and position // Be sure the file is gone try { if (filepath != null) { File file = new File(filepath); if (file != null) file.delete(); } } // If an exception, just continue below catch (Exception e) { } // Set the size and position to the full vnmrj frame setDefaultSizePosition(); }