You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Alexander Nozik <al...@gmail.com> on 2015/07/25 17:13:14 UTC

[VFS2] What is the best way to convert regular FIle to FileObject

Hello,
I've got a program, part of which is based on regular local file system 
and part is file system independent. So sometimes I need to convert 
regular local Files to VFS FileObjects. What is the simplest way to do 
that? It should be very simple, but I haven't found it in the 
documentations.

With best regards, Alexander Nozik.

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


Re: [VFS2] What is the best way to convert regular FIle to FileObject

Posted by Alexander Nozik <al...@gmail.com>.
Thank you very much. I completely missed VFS class and only just found 
it after reading documentation again more thoroughly.

With best regards, Alexander Nozik.

On 25-Jul-15 18:36, Bernd Eckenfels wrote:
> Hello,
>
> yes you always need a configured FSM for anything VFS. If you do not
> have special needs you can use the "system global" auto configured one:
>
> FileObject fo = VFS.getManager().toFileObject(file);
>
> See also http://commons.apache.org/proper/commons-vfs/api.html
>
> Gruss
> Bernd
>
>
>   Am Sat, 25 Jul 2015
> 18:28:36 +0300 schrieb Alexander Nozik <al...@gmail.com>:
>
>> Tried that. In order to do so, I need to create that manager first.
>> If I try to create either DefaultFileSystemManager or
>> StandardFileSystemManager and use them, I get "FileSystemException:
>> Could not find a file provider which can handle local files." in both
>> cases. I believe I need to somehow build a provider for local files,
>> but it not obvious from documentation how to do so. If I try to use
>> DefaultLocalFileProvider directly it throws internal
>> NullPointerException. Could you provide a code to build local file
>> system?
>>
>>
>> On 25-Jul-15 18:17, Bernd Eckenfels wrote:
>>> Hello,
>>>
>>> you can use FileSystemManager.toFileObject(File):
>>>
>>> https://commons.apache.org/proper/commons-vfs/apidocs/org/apache/commons/vfs2/FileSystemManager.html#toFileObject%28java.io.File%29
>>>
>>> Gruss
>>> Bernd
>>>
>>> Am Sat, 25 Jul 2015 18:13:14 +0300
>>> schrieb Alexander Nozik <al...@gmail.com>:
>>>
>>>> Hello,
>>>> I've got a program, part of which is based on regular local file
>>>> system and part is file system independent. So sometimes I need to
>>>> convert regular local Files to VFS FileObjects. What is the
>>>> simplest way to do that? It should be very simple, but I haven't
>>>> found it in the documentations.
>>>>
>>>> With best regards, Alexander Nozik.
>>>>
>>>> ---------------------------------------------------------------------
>>>> 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


Re: [VFS2] What is the best way to convert regular FIle to FileObject

Posted by Bernd Eckenfels <ec...@zusammenkunft.net>.
Hello,

yes you always need a configured FSM for anything VFS. If you do not
have special needs you can use the "system global" auto configured one:

FileObject fo = VFS.getManager().toFileObject(file);

See also http://commons.apache.org/proper/commons-vfs/api.html

Gruss
Bernd


 Am Sat, 25 Jul 2015
18:28:36 +0300 schrieb Alexander Nozik <al...@gmail.com>:

> Tried that. In order to do so, I need to create that manager first.
> If I try to create either DefaultFileSystemManager or 
> StandardFileSystemManager and use them, I get "FileSystemException: 
> Could not find a file provider which can handle local files." in both 
> cases. I believe I need to somehow build a provider for local files,
> but it not obvious from documentation how to do so. If I try to use 
> DefaultLocalFileProvider directly it throws internal
> NullPointerException. Could you provide a code to build local file
> system?
> 
> 
> On 25-Jul-15 18:17, Bernd Eckenfels wrote:
> > Hello,
> >
> > you can use FileSystemManager.toFileObject(File):
> >
> > https://commons.apache.org/proper/commons-vfs/apidocs/org/apache/commons/vfs2/FileSystemManager.html#toFileObject%28java.io.File%29
> >
> > Gruss
> > Bernd
> >
> > Am Sat, 25 Jul 2015 18:13:14 +0300
> > schrieb Alexander Nozik <al...@gmail.com>:
> >
> >> Hello,
> >> I've got a program, part of which is based on regular local file
> >> system and part is file system independent. So sometimes I need to
> >> convert regular local Files to VFS FileObjects. What is the
> >> simplest way to do that? It should be very simple, but I haven't
> >> found it in the documentations.
> >>
> >> With best regards, Alexander Nozik.
> >>
> >> ---------------------------------------------------------------------
> >> 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


Re: [VFS2] What is the best way to convert regular FIle to FileObject

Posted by Alexander Nozik <al...@gmail.com>.
Tried that. In order to do so, I need to create that manager first. If I 
try to create either DefaultFileSystemManager or 
StandardFileSystemManager and use them, I get "FileSystemException: 
Could not find a file provider which can handle local files." in both 
cases. I believe I need to somehow build a provider for local files, but 
it not obvious from documentation how to do so. If I try to use 
DefaultLocalFileProvider directly it throws internal NullPointerException.
Could you provide a code to build local file system?


On 25-Jul-15 18:17, Bernd Eckenfels wrote:
> Hello,
>
> you can use FileSystemManager.toFileObject(File):
>
> https://commons.apache.org/proper/commons-vfs/apidocs/org/apache/commons/vfs2/FileSystemManager.html#toFileObject%28java.io.File%29
>
> Gruss
> Bernd
>
> Am Sat, 25 Jul 2015 18:13:14 +0300
> schrieb Alexander Nozik <al...@gmail.com>:
>
>> Hello,
>> I've got a program, part of which is based on regular local file
>> system and part is file system independent. So sometimes I need to
>> convert regular local Files to VFS FileObjects. What is the simplest
>> way to do that? It should be very simple, but I haven't found it in
>> the documentations.
>>
>> With best regards, Alexander Nozik.
>>
>> ---------------------------------------------------------------------
>> 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


Re: [VFS2] What is the best way to convert regular FIle to FileObject

Posted by Bernd Eckenfels <ec...@zusammenkunft.net>.
Hello,

you can use FileSystemManager.toFileObject(File):

https://commons.apache.org/proper/commons-vfs/apidocs/org/apache/commons/vfs2/FileSystemManager.html#toFileObject%28java.io.File%29

Gruss
Bernd

Am Sat, 25 Jul 2015 18:13:14 +0300
schrieb Alexander Nozik <al...@gmail.com>:

> Hello,
> I've got a program, part of which is based on regular local file
> system and part is file system independent. So sometimes I need to
> convert regular local Files to VFS FileObjects. What is the simplest
> way to do that? It should be very simple, but I haven't found it in
> the documentations.
> 
> With best regards, Alexander Nozik.
> 
> ---------------------------------------------------------------------
> 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