on 05-21-2012 10:41 AM
Hi,
i tried acces XML file from unix box in portal application but i unable to connect .I have host name,user name,password,remote path .
I tried like
String password, String remotePath, String localPath) throws IOException {
// we first set strict key checking off
FileSystemOptions fsOptions = new FileSystemOptions();
SftpFileSystemConfigBuilder.getInstance().setStrictHostKeyChecking(
fsOptions, "no");
// now we create a new filesystem manager
DefaultFileSystemManager fsManager = (DefaultFileSystemManager) VFS
.getManager();
// the url is of form sftp://user:pass@host/remotepath/
String uri = "sftp://" + user + ":" + password + "@" + host
+ "/" + remotePath;
// get file object representing the local file
FileObject fo = fsManager.resolveFile(uri, fsOptions);
// open input stream from the remote file
BufferedInputStream is = new BufferedInputStream(fo.getContent()
.getInputStream());
// open output stream to local file
OutputStream os = new BufferedOutputStream(new FileOutputStream(
localPath));
int c;
// do copying
while ((c = is.read()) != -1) {
os.write(c);
}
os.close();
is.close();
// close the file object
fo.close();
// NOTE: if you close the file system manager, you won't be able to
// use VFS again in the same VM. If you wish to copy multiple files,
// make the fsManager static, initialize it once, and close just
// before exiting the process.
fsManager.close();
System.out.println("Finished copying the file");
Please provide me solution.
regards,
Nari.
is the File Server accessible from Portal Server?
You culd look at other option of Connecting this File Server via FileSystem Repository manager in KM. In that way the File resposiroty would appear in KM as one of the root repository. From there you can read/write files using KM APIs.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.