Examples of File


Examples of java.io.File

    String id)
    throws Exception {
    if (bean == null) {
      FileInputStream fis =
        new FileInputStream(
          new File(
            servlet.getServletContext().getRealPath(
              "../../../conf/resources.xml")));
      bean = ResourceXmlBean.parse(fis);
      fis.close();
    }
View Full Code Here

Examples of java.io.File

  public static Vector getResourceXmlBeans(HttpServlet servlet)
    throws Exception {
    if (bean == null) {
      FileInputStream fis =
        new FileInputStream(
          new File(
            servlet.getServletContext().getRealPath(
              "../../../conf/resources.xml")));
      bean = ResourceXmlBean.parse(fis);
      fis.close();
    }
View Full Code Here

Examples of java.io.File

          "\n      You will need to manually create one -ds.xml for each JDBC DataSource " +
          "\n      with a JNDI name of <connector binding name>DS, " +
          "\n      where any spaces in the name are replace by _");
      System.exit(-1);
    }
    File file = new File(args[0]);
    if (!file.exists()) {
      System.err.println(args[0] + " does not exist."); //$NON-NLS-1$
      System.exit(-1);
    }
    String fullName = file.getName();
    String fileName = fullName.substring(0, fullName.length() - 4);
    String ext = FileUtils.getExtension(file);
    if (ext == null) {
      System.err.println(fullName + " is not a vdb or xml file."); //$NON-NLS-1$
      System.exit(-1);
    }
    ext = ext.toLowerCase();
    if (ext.endsWith("vdb")) {
      File dir = createTempDirectory();
      try {
        extract(file, dir);
        File metainf = new File(dir, "META-INF");
        File config = new File(dir, "ConfigurationInfo.def");
        File manifest = new File(dir, "MetaMatrix-VdbManifestModel.xmi");
        if (manifest.exists()) {
          String configStr = ObjectConverterUtil.convertFileToString(config);
          String manifestStr = ObjectConverterUtil.convertFileToString(manifest);
          int index = configStr.lastIndexOf("</VDB>");
          int manifestBegin = manifestStr.indexOf("<xmi");
          configStr = configStr.substring(0, index) + manifestStr.substring(manifestBegin) + "</VDB>";
          FileUtils.write(configStr.getBytes(), config);
          manifest.delete();
        }
        transformConfig(config, "/vdb.xsl", new StreamResult(new File(metainf, "vdb.xml")));
        config.delete();
        FileOutputStream out = new FileOutputStream(new File(file.getParent(), fileName + "_70.vdb"));
        ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(out));
        int parentLength = dir.getPath().length();
        addDirectory(dir, zos, parentLength);
        zos.close();
      } finally {
        FileUtils.removeDirectoryAndChildren(dir);
      }
    } else if (ext.endsWith("xml") || ext.endsWith("def")){
      File parent = file.getParentFile();
      transformConfig(file, "/vdb.xsl", new StreamResult(new File(parent, fileName + "-vdb.xml")));
    } else {
      System.err.println(fullName + " is not a vdb or xml file.  Run with no arguments for help."); //$NON-NLS-1$
      System.exit(-1);
    }
  }
View Full Code Here

Examples of java.io.File

  private static void addDirectory(File dir, ZipOutputStream zos,
      int parentLength) throws IOException {
    String[] files = dir.list();
    for (String entry : files) {
      File f = new File(dir, entry);
      if (f.isDirectory()) {
        addDirectory(f, zos, parentLength);
      } else {
        ZipEntry e = new ZipEntry(f.getPath().substring(parentLength));
        zos.putNextEntry(e);
        FileUtils.write(f, zos);
        zos.closeEntry();
      }
    }
View Full Code Here

Examples of java.io.File

      // grab a zip file entry
      ZipEntry entry = (ZipEntry) zipFileEntries.nextElement();

      String currentEntry = entry.getName();

      File destFile = new File(unzipDestinationDirectory, currentEntry);

      // grab file's parent directory structure
      File destinationParent = destFile.getParentFile();

      // create the parent directory structure if needed
      destinationParent.mkdirs();

      // extract file if not a directory
      if (!entry.isDirectory()) {
        ObjectConverterUtil.write(zipFile.getInputStream(entry),
            destFile);
View Full Code Here

Examples of java.io.File

    }
    zipFile.close();
  }

  static File createTempDirectory() throws IOException {
    File temp = File.createTempFile("temp", Long.toString(System.nanoTime()));

    temp.delete();

    if (!(temp.mkdir())) {
      throw new IOException("Could not create temp directory: "
          + temp.getAbsolutePath());
    }

    return temp;
  }
View Full Code Here

Examples of java.io.File

     
    return deploymentBaseName;
  }

  public VirtualFile applyTemplate(DeploymentTemplateInfo sourceInfo) throws Exception {
    File dsXml = File.createTempFile(getClass().getSimpleName(),TranslatorParserDeployer.TRANSLATOR_SUFFIX);
    writeTemplate(dsXml, sourceInfo);
    return VFS.getRoot(dsXml.toURI());
  }
View Full Code Here

Examples of java.io.File

  public void setUseDisk(boolean flag) {
    this.useDisk = flag;
  }

  public void setDiskDirectory(String dir) {
    this.bufferDir = new File(dir, "buffer"); //$NON-NLS-1$
  }
View Full Code Here

Examples of java.io.File

   * @param url
   * @return cacheFile
   */
  protected File getCacheFile(URL url) {
    // does the file exists on the filesystem ?
    File cacheFile = new File(url2Filename(url));
    if (! (cacheFile.exists() && (cacheFile.isFile()))) {
    return null;
    }
    return cacheFile;
  }
View Full Code Here

Examples of java.io.File

   * simple heuristic to determine the possible MIME type.
   */
  public void removeDocument(URL u) {
  String ext = getExtension(u);
  if (ext == null) return;
  File cacheFile = getCacheFile(u);
  if (cacheFile == null) return ;
 
  cacheFile.delete();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.