How to get all files present from UNC path java?

707 views Asked by At

Am try to get all files present in UNC path using apache commons-vfs2 library.

But am not find way to list files present in UNC path with valid credentials.And then do manipulations in all files.

I tried following code for access file present in UNC.

String domain="xxxxx";
String userName="xyz";
String password="aabbcc";
File f=new File("E:/destination");
String remoteFilePath="\\\\hostname\\foldername";
UserAuthenticator auth=new StaticUserAuthenticator(domain, userName, password);
FileSystemOptions opts=new FileSystemOptions();
DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, auth);
FileObject fo=VFS.getManager().resolveFile(remoteFilePath,opts);
FileObject destn=VFS.getManager().resolveFile(f.getAbsolutePath());
destn.copyFrom(fo,Selectors.SELECT_SELF);
destn.close();

Here i have given filename append with remoteFilePath it moves that file into my destination directory.

If i give only directory name in remoteFilePath it not worked.

Now i need to get all files present in "UNC Path" without give filename.After reading those files then do some changes inside files to be moved into destination directory.

Anyone suggest way to do it?

0

There are 0 answers