Package org.apache.commons.vfs

Examples of org.apache.commons.vfs.FileObject.createFile()


    try {
      FileSystemManager fsManager = VFS.getManager();
      FileObject dir = fsManager.resolveFile("ram://test-dir");
      dir.createFolder();
      FileObject chapter1 = dir.resolveFile("chapter1.html", NameScope.CHILD);
      chapter1.createFile();
      IOUtils.copy(this.getClass().getResourceAsStream("/book1/chapter1.html"), chapter1.getContent().getOutputStream());
      Book bookFromDirectory = FilesetBookCreator.createBookFromDirectory(dir, Constants.CHARACTER_ENCODING);
      assertEquals(1, bookFromDirectory.getResources().size());
      assertEquals(1, bookFromDirectory.getSpine().size());
      assertEquals(1, bookFromDirectory.getTableOfContents().size());
View Full Code Here


    copyInputStreamToFileObject(inputStream, targetDir, targetFilename);
  }
 
  private void copyInputStreamToFileObject(InputStream inputStream, FileObject targetDir, String targetFilename) throws IOException {
    FileObject targetFile = targetDir.resolveFile(targetFilename, NameScope.DESCENDENT);
    targetFile.createFile();
    IOUtils.copy(inputStream, targetFile.getContent().getOutputStream());
    targetFile.getContent().close();
  }
}
View Full Code Here

      String chm1Dir = "/chm1";
      Iterator<String> lineIter = IOUtils.lineIterator(ChmParserTest.class.getResourceAsStream(chm1Dir + "/filelist.txt"), Constants.CHARACTER_ENCODING);
      while(lineIter.hasNext()) {
        String line = lineIter.next();
        FileObject file = dir.resolveFile(line, NameScope.DESCENDENT);
        file.createFile();
        IOUtils.copy(this.getClass().getResourceAsStream(chm1Dir + "/" + line), file.getContent().getOutputStream());
        file.getContent().close();
      }
     
      Book chmBook = ChmParser.parseChm(dir, Constants.CHARACTER_ENCODING);
View Full Code Here

      if (WIN_PATH.matcher(path).matches()){
        path = path.substring(1);
      }

      //if(!tempFile.exists()){
        tempFile.createFile();

        in = fileObject.getContent().getInputStream();
        out = tempFile.getContent().getOutputStream();
        IOUtils.copy(in, out);
View Full Code Here

        if(!tempFile.exists() || tempFile.getContent().getSize() == 0){
          InputStream in = null;
          OutputStream out = null;
          try{
            if(!tempFile.exists()){
              tempFile.createFile();
            }

            // download and save remote file.
            URL remote = new URL(systemId);
            URLConnection conn = remote.openConnection();
View Full Code Here

                File file = (File) request.getFilesByParamName().get("file");
                if (file != null) {
                    String fileName = file.getName();
                    FileObject fileObject = currentDir.resolveFile(fileName);
                    if (!fileObject.exists()) {
                        fileObject.createFile();
                        OutputStream os = fileObject.getContent().getOutputStream(true);
                        InputStream is = new BufferedInputStream(new FileInputStream(file));
                        IOUtils.copy(is, os);
                        is.close();
                        os.close();
View Full Code Here

              if (rem == null) {
                createLocalFile(new File(root.getPath() + fcd.filename));
              } else {
                object = rem.resolveFile(fcd.filename);
                if (object.getType().equals(FileType.IMAGINARY)) {
                  object.createFile();
                  fileViewer.refresh();
                  // Now open it
                  RemoteFileEditorInput input = new RemoteFileEditorInput(object);
                  IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
                      .getActivePage();
View Full Code Here

            FileObject object;
            try {
              object = rem.resolveFile(fcd.filename);
              if (object.getType().equals(FileType.IMAGINARY)) {
                object.createFile();
                fileViewer.refresh();
                // Now open it
                RemoteFileEditorInput input = new RemoteFileEditorInput(object);
                IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
                    .getActivePage();
View Full Code Here

    if ( d.open() == Window.OK) {
     
      try {
        String newFolder = d.getValue();
        FileObject newFile = parent.resolveFile(newFolder);
        newFile.createFile();
       
      } catch (FileSystemException e) {
        MessageBoxError( e.getMessage());
      }
    }
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.