/**
  * 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();
 }
예제 #2
0
 public EmailContent(String fileName) throws URISyntaxException, IOException {
   URL entry = GitActivator.getDefault().getBundleContext().getBundle().getEntry(fileName);
   if (entry == null) throw new IOException("File not found: " + fileName);
   BufferedReader reader = new BufferedReader(new InputStreamReader(entry.openStream()));
   String line = null;
   try {
     title = reader.readLine();
     StringBuilder stringBuilder = new StringBuilder();
     String ls = System.getProperty("line.separator");
     while ((line = reader.readLine()) != null) {
       stringBuilder.append(line);
       stringBuilder.append(ls);
     }
     content = stringBuilder.toString();
   } finally {
     reader.close();
   }
 }
예제 #3
0
  private byte[] readMultiPartChunk(ServletInputStream requestStream, String contentType)
      throws IOException {
    // fast forward stream past multi-part header
    int boundaryOff = contentType.indexOf("boundary="); // $NON-NLS-1$
    String boundary = contentType.substring(boundaryOff + 9);
    BufferedReader reader =
        new BufferedReader(new InputStreamReader(requestStream, "ISO-8859-1")); // $NON-NLS-1$
    StringBuffer out = new StringBuffer();
    // skip headers up to the first blank line
    String line = reader.readLine();
    while (line != null && line.length() > 0) line = reader.readLine();
    // now process the file

    char[] buf = new char[1000];
    int read;
    while ((read = reader.read(buf)) > 0) {
      out.append(buf, 0, read);
    }
    // remove the boundary from the output (end of input is \r\n--<boundary>--\r\n)
    out.setLength(out.length() - (boundary.length() + 8));
    return out.toString().getBytes("ISO-8859-1"); // $NON-NLS-1$
  }
 // Fully read the file pointed to by the given path
 private String read(String path) {
   File file = new File(path);
   if (!file.exists()) return null;
   StringBuffer buffer = new StringBuffer();
   BufferedReader reader = null;
   try {
     reader = new BufferedReader(new FileReader(file));
     for (String line = reader.readLine(); line != null; line = reader.readLine()) {
       buffer.append(line);
       buffer.append('\n');
     }
   } catch (IOException e) {
     // TODO
   } finally {
     if (reader != null)
       try {
         reader.close();
       } catch (IOException e) {
         // ignore
       }
   }
   return buffer.toString();
 }