commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Benson <gudnabr...@yahoo.com>
Subject RE: [vfs] Copying byte[] to destination file
Date Fri, 23 Jan 2009 18:58:27 GMT

--- "Walter, Patrick A"
<Patrick.A.Walter@usa-spaceops.com> wrote:

> OK... 
> Do you mean the IOUtil's from VFS or java? 

I meant from commons-io.

> There is a VFS FileUtil with a
> writeContent(FileObject file, java.io.OutputStream
> outstr) method. But what I want something like
> writeContent(byte[] data,
> java.io.OutputStream outstr) or
> writeContent(byte[] data, FileObject out) 
> 
> What does VFS have for buffering?

Nothing I can see, but again, I don't have any
particular expertise with the API.

-Matt

> 
> thanks
> 
> 
> 
> -----Original Message-----
> From: Matt Benson [mailto:gudnabrsam@yahoo.com] 
> Sent: Friday, January 23, 2009 12:37 PM
> To: Commons Users List
> Subject: RE: [vfs] Copying byte[] to destination
> file
> 
> 
> --- "Walter, Patrick A"
> <Patrick.A.Walter@usa-spaceops.com> wrote:
> 
> > Thanks for your quick response!!!
> > 
> > Ok so I would do some thing like this...
> > 
> > void writeToFile(byte[] data, String outfilename)
> {
> >    FileSystemManager fsm = VFS.getManager();
> >    FileObject outFileObject =
> > fsm.resolveFile(outfilename);
> >    OutputStream os =
> > outFileObject.getContent().getOutputStream();
> >    os.write(data);
> > }
> > 
> > Does this look right?
> > Will this work for all types of file output (FTP,
> Local, HTTP, HTTPS, 
> > SFTP, et.)?
> 
> I am not an authority on VFS, but that looks correct
> (beyond that I would, as I stated before, use some
> sort of buffering strategy in the write such as that
> employed by IOUtils' copy(..) methods).
> 
> -Matt
> 
> > 
> > thanks
> > 
> > 
> > 
> > 
> > -----Original Message-----
> > From: Matt Benson [mailto:gudnabrsam@yahoo.com]
> > Sent: Friday, January 23, 2009 12:01 PM
> > To: Commons Users List
> > Subject: Re: [vfs] Copying byte[] to destination
> file
> > 
> > Note that I have added the component ID to the
> subject
> > line:
> > 
> > I'm not sure I entirely understand the question. 
> If I wanted to copy 
> > a byte[] to a VFS FileObject I would use
> commons-io IOUtils to copy 
> > the byte[] to
> fileObject.getContent().getOutputStream().  Does
> this 
> > help?
> > 
> > -Matt
> > 
> > --- "Walter, Patrick A"
> > <Patrick.A.Walter@usa-spaceops.com> wrote:
> > 
> > > Trying to find API to send in a byte[] to copy
> to
> > destination. We
> > > build a byte[] that would normally be written to
> a
> > file, BUT I thought
> > > it would be more efficient to just tell VFS API
> to
> > send the data to
> > > the destination.
> > >  
> > > Is there a way to do this, besides creating a
> file
> > first???
> > >  
> > > thanks
> > > 
> > 
> > 
> > 
> >       
> > 
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > user-unsubscribe@commons.apache.org
> > For additional commands, e-mail:
> > user-help@commons.apache.org
> > 
> > 
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > user-unsubscribe@commons.apache.org
> > For additional commands, e-mail:
> > user-help@commons.apache.org
> > 
> > 
> 
> 
> 
>       
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@commons.apache.org
> For additional commands, e-mail:
> user-help@commons.apache.org
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@commons.apache.org
> For additional commands, e-mail:
> user-help@commons.apache.org
> 
> 



      

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message