/** * Reads and returns the VM arguments specified in the running platform's .ini file, or am empty * string if none. * * @return VM arguments specified in the running platform's .ini file */ public static String getIniVMArgs() { File installDirectory = new File(Platform.getInstallLocation().getURL().getFile()); if (Platform.getOS().equals(Platform.OS_MACOSX)) installDirectory = new File(installDirectory, "Eclipse.app/Contents/MacOS"); // $NON-NLS-1$ File eclipseIniFile = new File(installDirectory, "eclipse.ini"); // $NON-NLS-1$ BufferedReader in = null; StringBuffer result = new StringBuffer(); if (eclipseIniFile.exists()) { try { in = new BufferedReader(new FileReader(eclipseIniFile)); String str; boolean vmargs = false; while ((str = in.readLine()) != null) { if (vmargs) { if (result.length() > 0) result.append(" "); // $NON-NLS-1$ result.append(str); } // start concat'ng if we have vmargs if (vmargs == false && str.equals("-vmargs")) // $NON-NLS-1$ vmargs = true; } } catch (IOException e) { MDECore.log(e); } finally { if (in != null) try { in.close(); } catch (IOException e) { MDECore.log(e); } } } return result.toString(); }
private static PermissionInfo[] getPermissionInfos(URL resource, Framework framework) { if (resource == null) return null; PermissionInfo[] info = EMPTY_PERM_INFO; DataInputStream in = null; try { in = new DataInputStream(resource.openStream()); ArrayList permissions = new ArrayList(); BufferedReader reader; try { reader = new BufferedReader(new InputStreamReader(in, "UTF8")); // $NON-NLS-1$ } catch (UnsupportedEncodingException e) { reader = new BufferedReader(new InputStreamReader(in)); } while (true) { String line = reader.readLine(); if (line == null) /* EOF */ break; line = line.trim(); if ((line.length() == 0) || line.startsWith("#") || line.startsWith("//")) /* comments */ // $NON-NLS-1$ //$NON-NLS-2$ continue; try { permissions.add(new PermissionInfo(line)); } catch (IllegalArgumentException iae) { /* incorrectly encoded permission */ if (framework != null) framework.publishFrameworkEvent(FrameworkEvent.ERROR, framework.getBundle(0), iae); } } int size = permissions.size(); if (size > 0) info = (PermissionInfo[]) permissions.toArray(new PermissionInfo[size]); } catch (IOException e) { // do nothing } finally { try { if (in != null) in.close(); } catch (IOException ee) { // do nothing } } return info; }