Package org.apache.commons.vfs

Examples of org.apache.commons.vfs.FileContent


        }
        else
        {
            // Stat the file
            System.out.println(file.getName());
            final FileContent content = file.getContent();
            System.out.println("Size: " + content.getSize() + " bytes.");
            final DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);
            final String lastMod = dateFormat.format(new Date(content.getLastModifiedTime()));
            System.out.println("Last modified: " + lastMod);
        }
    }
View Full Code Here


      // as of version 3.7 we do not need to check anything other than that the version information is there
      // later we may have to add additional checks in here to filter out known broken versions.

      final String localPath = pathModel.getLocalPath();
      final FileObject object = fileSystemRoot.resolveFile(localPath);
      final FileContent content = object.getContent();
      final String majorVersionText = (String) fileSystem.getAttribute(WebSolutionFileSystem.MAJOR_VERSION);

      if (StringUtils.isEmpty(majorVersionText) == false)
      {
        final String paramService = (String) content.getAttribute("param-service-url");
        if (StringUtils.isEmpty(paramService))
        {
          return null;
        }
        if (paramService.startsWith("http://") || paramService.startsWith("https://"))
View Full Code Here

            if (name == null) {
                throw new MessagingException("No output name available. Cannot output message!");
            }
            else {
                FileObject newFile = directory.resolveFile(name);
                FileContent content = newFile.getContent();
                if (content != null) {
                    out = content.getOutputStream();
                }
                if (out == null) {
                    throw new MessagingException("No output stream available for output name: " + name);
                }
            }
View Full Code Here

     */
    public void get(String srcVfsURI, File destination) throws IOException {
        VfsResource src = new VfsResource(srcVfsURI, getVFSManager());
        fireTransferInitiated(src, TransferEvent.REQUEST_GET);
        try {
            FileContent content = src.getContent();
            if (content == null) {
                throw new IllegalArgumentException("invalid vfs uri " + srcVfsURI
                        + ": no content found");
            }
            FileUtil.copy(content.getInputStream(), destination, _progress);
        } catch (IOException ex) {
            fireTransferError(ex);
            throw ex;
        } catch (RuntimeException ex) {
            fireTransferError(ex);
View Full Code Here

        // Get fileNew content as a binary stream
        final byte[] expectedBin = expected.getBytes("utf-8");

        // Check lengths - this depends on the returned format of content.getSize()
        final FileContent content = file.getContent();
        System.out.println("file: " + file.getURL() + " type: " + file.getType());
        System.out.println("content: " + content + " map: " + content.getAttributes());
        Map map = content.getAttributes();
        Iterator it = map.keySet().iterator();

        while(it.hasNext())
        {
            String key = (String)(it.next());
        }


        assertEquals("same content length", expectedBin.length, content.getSize());

        // Read content into byte array
        final InputStream instr = content.getInputStream();
        final ByteArrayOutputStream outstr;
        try {
            outstr = new ByteArrayOutputStream(expectedBin.length);
            final byte[] buffer = new byte[256];
            int nread = 0;
View Full Code Here

    protected void processFile(FileObject file) throws Exception {
        // SM-192: Force close the file, so that the cached informations are cleared
        file.close();
        String name = file.getName().getURI();
        FileContent content = file.getContent();
        content.close();
        InputStream in = content.getInputStream();
        if (in == null) {
            throw new JBIException("No input available for file!");
        }
        RobustInOnly exchange = getExchangeFactory().createRobustInOnlyExchange();
        NormalizedMessage message = exchange.createMessage();
        exchange.setInMessage(message);
        marshaler.readMessage(exchange, message, in, name);
        getDeliveryChannel().sendSync(exchange);
        in.close();
        content.close();
        if (exchange.getError() != null) {
            throw exchange.getError();
        }
    }
View Full Code Here

        }

        FileObject webFile = fsManager.resolveFile(this.httpUri, defaultOpts);

        System.out.println("name: " + webFile.getName().toString());
        FileContent fc = webFile.getContent();
        String[] atts = fc.getAttributeNames();
        for (String s : atts) {
            System.out.println("att: " + s);
        }

        FileContentInfo fci = fc.getContentInfo();
        System.out.println("encoding: " + fci.getContentEncoding());
        System.out.println("contentType: " + fci.getContentType());
        System.out.println("size: " + fc.getSize());
    }
View Full Code Here

        // Get fileNew content as a binary stream
        final byte[] expectedBin = expected.getBytes("utf-8");

        // Check lengths - this depends on the returned format of content.getSize()
        final FileContent content = file.getContent();
        assertEquals("same content length", expectedBin.length, content.getSize());

        // Read content into byte array
        final InputStream instr = content.getInputStream();
        final ByteArrayOutputStream outstr;
        try {
            outstr = new ByteArrayOutputStream(expectedBin.length);
            final byte[] buffer = new byte[256];
            int nread = 0;
View Full Code Here

   */
  public void get(String srcVfsURI, File destination) throws IOException {
    VfsResource src = new VfsResource(srcVfsURI, getVFSManager());
    fireTransferInitiated(src, TransferEvent.REQUEST_GET);
    try {
      FileContent content = src.getContent();
            if (content == null) {
                throw new IllegalArgumentException("invalid vfs uri "+srcVfsURI+": no content found");
            }
            FileUtil.copy(content.getInputStream(), destination, _progress);
    } catch (IOException ex) {
      fireTransferError(ex);
      throw ex;
    } catch (RuntimeException ex) {
      fireTransferError(ex);
View Full Code Here

    protected void processFile(FileObject file) throws Exception {
        // SM-192: Force close the file, so that the cached informations are cleared
        file.close();
        String name = file.getName().getURI();
        FileContent content = file.getContent();
        content.close();
        InputStream in = content.getInputStream();
        if (in == null) {
            throw new JBIException("No input available for file!");
        }
        RobustInOnly exchange = getExchangeFactory().createRobustInOnlyExchange();
        NormalizedMessage message = exchange.createMessage();
        exchange.setInMessage(message);
        marshaler.readMessage(exchange, message, in, name);
        getDeliveryChannel().sendSync(exchange);
        in.close();
        content.close();
        if (exchange.getError() != null) {
            throw exchange.getError();
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.vfs.FileContent

Copyright © 2018 www.massapicom. 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.