Skip to content

Latest commit

 

History

History
96 lines (68 loc) · 2.6 KB

README.md

File metadata and controls

96 lines (68 loc) · 2.6 KB

common-vfs2-nfs

nfs provider for java common vfs2

License

Provenance

This is a fork of common-vfs2-nfs from profuz/common-vfs2-nfs .

The purpose of my fork is to update dependencies to yanfs 1.4 and commons-vfs2 2.9.0

<repository>
    <id>mcbluna.net</id>
    <url>https://mcbluna.net/repository/</url>
</repository>

<dependency>
    <groupId>net.mcbluna</groupId>
    <artifactId>common-vfs2-nfs</artifactId>
    <version>1.0.4</version>
</dependency>

Project "common-vfs2-nfs" is a NFS provider for Commons VFS.

Requirements

Project "commons-vfs2-nfs" requires:

Building

mvn clean package dependency:tree

Example

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import org.apache.commons.vfs2.FileObject;
import org.apache.commons.vfs2.FileSystemException;
import org.apache.commons.vfs2.FileSystemManager;
import org.apache.commons.vfs2.VFS;

public class Main {

	public static void main(String[] args) {
	    try {
		FileSystemManager fileSystemManager = VFS.getManager();

		String path = "nfs://10.0.202.122//opt/glog/a.txt";
	        FileObject fileObject = fileSystemManager.resolveFile();
	        if (fileObject == null) {
	            throw new IOException("File cannot be resolved: " + path);
	        }
	        if (!fileObject.exists()) {
	            throw new IOException("File does not exist: " + path);
	        }
	        System.out.println(fileObject.getName().getPath());
	        BufferedReader stream = new BufferedReader(new InputStreamReader(fileObject.getContent().getInputStream(), "utf-8"));
        	String line = null;
        	while((line = stream.readLine()) != null) {
        		System.out.println(line);
        	}
	    } catch (Exception e) {
		e.printStackTrace();
	    }

	}

}

License

Copyright 2016 Song Sheng

Licensed under the MIT License,(the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    https://opensource.org/licenses/MIT

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.