Beispiel #1
0
 private void doImportFromURL(HttpServletRequest req, HttpServletResponse resp)
     throws IOException, ServletException {
   URL source = getSourceURL();
   IOUtilities.pipe(
       source.openStream(),
       new FileOutputStream(new File(getStorageDirectory(), FILE_DATA), true),
       true,
       true);
   completeTransfer(req, resp);
 }
 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();
   }
 }
  public static URL computeURL(
      ISchemaDescriptor parentDesc, String schemaLocation, List<IPath> additionalSearchLocations)
      throws MalformedURLException {
    URL parentURL = parentDesc == null ? null : parentDesc.getSchemaURL();
    if (schemaLocation.startsWith("schema://")) { // $NON-NLS-1$
      // extract plug-in ID
      IPath path = new Path(schemaLocation.substring(9));
      return getPluginRelativePath(
          path.segment(0), path.removeFirstSegments(1), parentURL, additionalSearchLocations);
    }

    if (parentURL == null) return null;

    // parent-relative location
    IPath path = new Path(parentURL.getPath());
    path = path.removeLastSegments(1).append(schemaLocation);
    return new URL(parentURL.getProtocol(), parentURL.getHost(), path.toString());
  }
 public IncludedSchemaDescriptor(URL schemaURL) {
   fSchemaURL = schemaURL;
   File file = new File(fSchemaURL.getFile());
   if (file.exists()) fLastModified = file.lastModified();
 }