- Notifications
You must be signed in to change notification settings - Fork0
jcon: Java connector to remote filesystem (remote file access in Java)
License
marlonrcfranco/jcon
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Java connector to remote filesystem
Add the dependency to the pom.xml of your maven project
<dependency> <groupId>com.marlonrcfranco</groupId> <artifactId>jcon</artifactId> <version>1.0-SNAPSHOT</version></dependency>
Or direct download the jcon.jar clicking here:
You can import and instantiate theJcon
class.
importcom.marlonrcfranco.Jcon;
Jconjcon =newJcon("smb1");// "smb1", "smb23", "nfs" or "filesystem"/** Returns a String with the name of all the files an directories separated by "\n" */StringsList =jcon.listFiles("192.168.XXX.XXX","SharedFolder/subfolder/","Username","Password");/** Returns an ArrayList of objects according to the protocol.E.g. for filesystem protocol, it will return ArrayList<java.io.File>; for smb1 protocol, it will return ArrayList<jcifs.smb.SmbFile>, and so on. */ArrayList<SmbFile>aList =jcon.listFilesAsList("192.168.XXX.XXX","SharedFolder/subfolder/","Username","Password");
Jconjcon =newJcon("smb1");// "smb1", "smb23", "nfs" or "filesystem"/** Reads the content as a String */StringsContent =jcon.read("192.168.XXX.XXX","SharedFolder/subfolder/test.txt","Username","Password");/** Reads the content as byte[] (recommended for PDF and image files) */byte[]bContent =jcon.readBytes("192.168.XXX.XXX","SharedFolder/subfolder/test.txt","Username","Password");
Jconjcon =newJcon("smb1");// "smb1", "smb23", "nfs" or "filesystem"/** Writes the content as a String */StringsContent ="some string";jcon.write("192.168.XXX.XXX","SharedFolder/subfolder/test.txt","Username","Password",sContent);/** Writes the content as byte[] (recommended for PDF and image files)*/byte[]bContent ="some string".getBytes();jcon.writeBytes("192.168.XXX.XXX","SharedFolder/subfolder/test.txt","Username","Password",bContent);
Jconjcon =newJcon("smb1");// "smb1", "smb23", "nfs" or "filesystem"/** Deletes the directory "SharedFolder/subfolder/" and everything inside it */jcon.delete("192.168.XXX.XXX","SharedFolder/subfolder/","Username","Password");/** Deletes only the file "test.txt" in "SharedFolder/subfolder/" */jcon.delete("192.168.XXX.XXX","SharedFolder/subfolder/test.txt","Username","Password");
If you have Java installed, simply open a new terminal (Unix) or cmd (Windows) and type:
java -jar jcon.jar
It will appear as follows:
The interface provides easy access to remotelylist
,read
,write
ordelete
files and directories.
If you need some help, just typehelp
orh
For a quick info about the supported protocols, just typeconnectors
orc
List all the files and sub-directories in a remote path.
list[l] <connector> <path>,<IP>,<username>,<password>
For example:Using thesmb23
connector to list files ins a remote machine that usesSMB2 orSMB3 protocols
l smb23 \shared\my_directory,10.0.0.7,marlon,pass100%S3cuR3
Using thesmb1
connector to list files ins a remote machine that usesSMB1 protocol
l smb1 \shared\my_directory,10.0.0.7,marlon,pass100%S3cuR3
Obs: at version v1.0, when using the connectorfilesystem
, you don't need to provide any parameter besides the path.Example:
l fylesystem C:\User\marlon\Documents
Read a given file and print its content on terminal.It can read fromany file format (.pdf, .txt, .jpg, .png, ...)
read[r] <connector> <full_file_path>,<IP>,<username>,<password>
For example:
r smb23 \shared\my_directory\my_file.txt,10.0.0.7,marlon,pass100%S3cuR3
Obs: at version v1.0, when using the connectorfilesystem
, you don't need to provide any parameter besides the path.Example:
r fylesystem C:\User\marlon\Documents\my_file.html
Write to a given file whatever content you provide as the last parameter.It can write toany file format (.pdf, .txt, .jpg, .png, ...) and the content can be specified in binary.
write[w] <connector> <full_file_path>,<IP>,<username>,<password>,<content>
For example:
w smb23 \shared\my_directory\my_file.csv,10.0.0.7,marlon,pass100%S3cuR3,This is my content right here, (no matter if it is in between " or not)
Obs: at version v1.0, when using the connectorfilesystem
, you don't need to provide any parameter besides the path.Example:
w fylesystem C:\User\marlon\Documents\photo.png
Delete a given file.
delete[d] <connector> <full_file_path>,<IP>,<username>,<password>
For example:
d smb23 \shared\my_directory\my_file.csv,10.0.0.7,marlon,pass100%S3cuR3
Obs: at version v1.0, when using the connectorfilesystem
, you don't need to provide any parameter besides the path.Example:
d fylesystem C:\User\marlon\Documents\photo.png
About
jcon: Java connector to remote filesystem (remote file access in Java)
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.