commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bakary Dialaya DJIBA" <dial...@gmail.com>
Subject Re: [ understand VFS ]
Date Wed, 24 Sep 2008 15:27:58 GMT
sorry its a mistake, I mean userFolder.getChildren() throw that exception.
thanks,

On Wed, Sep 24, 2008 at 4:23 PM, James Carman <james@carmanconsulting.com>wrote:

> You weren't asking for the children of a folder when you did
> userFile.getChildren().  The userFile FileObject is a file, not a
> folder.
>
> On Wed, Sep 24, 2008 at 10:19 AM, Bakary Dialaya DJIBA
> <dialaya@gmail.com> wrote:
> > Based on this example,
> >>>FileObject rootDir = manager.resolveFile("sch:/");
> >>> FileObject userFolder = rootDir.resolveFile(userName);
> >>> userFolder.createFolder();
> >>> FileObject userFile = userFolder.resolveFile("anotherFolder");
> >>> userFile.createFolder();
> >
> > userFile.getChildren() throws a null Pointer Exception:
> > org.apache.commons.vfs.FileSystemException: Could not list the contents
> of
> > folder "sch:///bakary".
> > at
> >
> org.apache.commons.vfs.provider.AbstractFileObject.getChildren(AbstractFileObject.java:592)
> >
> > How can I get the children of userFolder, please?
> >
> >
> >
> > On Wed, Sep 24, 2008 at 12:21 PM, James Carman
> > <james@carmanconsulting.com>wrote:
> >
> >> No problem.  Glad to help!
> >>
> >> On Wed, Sep 24, 2008 at 4:15 AM, Bakary Dialaya DJIBA <
> dialaya@gmail.com>
> >> wrote:
> >> >  It works well.
> >> > Thanks.
> >> >
> >> > On Wed, Sep 24, 2008 at 2:10 AM, James Carman <
> >> james@carmanconsulting.com>wrote:
> >> >
> >> >> I wouldn't do any downcasting if you want it to be generic.  Use the
> >> >> FileObject API:
> >> >>
> >> >> FileObject rootDir = manager.resolveFile("sch:/");
> >> >> FileObject userFolder = rootDir.resolveFile(userName);
> >> >> userFolder.createFolder();
> >> >> FileObject userFile = userFolder.resolveFile("MyFile.txt");
> >> >> userFile.createFile();
> >> >>
> >> >> To get stuff into this "user file", you can use:
> >> >>
> >> >> File localFile = ...;
> >> >> FileObject localFileObject = manager.toFileObject(localFile);
> >> >> FileUtil.copyContent(localFileObject,userFile);
> >> >>
> >> >> On Tue, Sep 23, 2008 at 3:37 PM, Bakary Dialaya DJIBA <
> >> dialaya@gmail.com>
> >> >> wrote:
> >> >> > Hi,
> >> >> >
> >> >> > Given a FileSystem *fs* (extends abstractFS) and a FileObject
*fo
> >> >> *(extends
> >> >> > AbstractFO), how can I attach the fo to the fs?
> >> >> >
> >> >> > It's a silly question. I am trying to create a provider that I'll
> add
> >> to
> >> >> > the default manager (of VFS). The provider is added successfully
> but I
> >> >> > cannot make a link between *fs* and *fo*.
> >> >> >
> >> >> > To do this I write the code below:
> >> >> >
> >> >> > DefaultFileSystemManager manager new DefaultFileSystemManager();
> >> >> > MyProvider provider = new MyProvider();
> >> >> > FileSystemOptions fileSystemOptions = new FileSystemOptions();
> >> >> >
> >> >> > manager.addProvider("sch", provider);
> >> >> > manager.init();
> >> >> >
> >> >> > CustomFileObject fo =
> (CustomFileObject)manager.resolveFile("sch:/");
> >> >> >
> >> >> > CustomFileName fn = new CustomFileName("sch",
> >> >> "userName",FileType.FOLDER);
> >> >> >
> >> >> > CustomFileSystem fs = new CustomFileSystem(fn,fileSystemOptions);
> >> >> > fs.attach(fo);
> >> >> > System.out.println(fo.isAttached()); // return false
> >> >> > fo.doAttach();
> >> >> > System.out.println(fo.isAttached()); // return false
> >> >> >
> >> >> >
> >> >> > My second problème is that I don't know how to set my root file
> >> system.
> >> >> And
> >> >> > also fo.getParent() throw a null pointer exception.
> >> >> >
> >> >> > Someone can tell me how to do this:
> >> >> >
> >> >> > FS
> >> >> >  |__FileObject1 ...
> >> >> >  |
> >> >> >  |__FileObject2 ...
> >> >> >
> >> >> > or give me a tutorial to understand VFS API.
> >> >> >
> >> >> > Thanks & Regards.
> >> >> >
> >> >> >
> >> >> > --
> >> >> > Bakary,
> >> >> >
> >> >>
> >> >> ---------------------------------------------------------------------
> >> >> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> >> >> For additional commands, e-mail: user-help@commons.apache.org
> >> >>
> >> >>
> >> >
> >> >
> >> > --
> >> > Bakary,
> >> >
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> >> For additional commands, e-mail: user-help@commons.apache.org
> >>
> >>
> >
> >
> > --
> > Bakary,
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>


-- 
Bakary,

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message