Skip to content

Latest commit

 

History

History
261 lines (208 loc) · 8.75 KB

README.md

File metadata and controls

261 lines (208 loc) · 8.75 KB

GitHub release (latest by date) Build Status GitHub repo size GitHub top language GitHub GitHub stars

jcon

Java connector to remote filesystem


Supported protocols:


How to get it

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: GitHub Releases


How to use it


Via java code:

You can import and instantiate the Jcon class.

import com.marlonrcfranco.Jcon;


List all files and directories in a given path: 📂

Jcon jcon = new Jcon("smb1"); // "smb1", "smb23", "nfs" or "filesystem"

/** Returns a String with the name of all the files an directories separated by "\n" */
String sList = 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");


Read contents of a file: 📃

Jcon jcon = new Jcon("smb1"); // "smb1", "smb23", "nfs" or "filesystem"

/** Reads the content as a String */
String sContent = 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");


Write contents to a file: ✏️

Jcon jcon = new Jcon("smb1"); // "smb1", "smb23", "nfs" or "filesystem"

/** Writes the content as a String */
String sContent = "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);


Delete a file or directory: 💥

Jcon jcon = new Jcon("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");


Via console command:

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 remotely list, read, write or delete files and directories.


help[h] 🤔

If you need some help, just type help or h


connectors[c] 🔌

For a quick info about the supported protocols, just type connectors or c


list[l] 📂

List all the files and sub-directories in a remote path.

 list[l] <connector> <path>,<IP>,<username>,<password>

For example: Using the smb23 connector to list files ins a remote machine that uses SMB2 or SMB3 protocols

 l smb23 \shared\my_directory,10.0.0.7,marlon,pass100%S3cuR3

Using the smb1 connector to list files ins a remote machine that uses SMB1 protocol

 l smb1 \shared\my_directory,10.0.0.7,marlon,pass100%S3cuR3

Obs: at version v1.0, when using the connector filesystem, you don't need to provide any parameter besides the path. Example:

 l fylesystem C:\User\marlon\Documents


read[r] 📃

Read a given file and print its content on terminal. It can read from any 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 connector filesystem, you don't need to provide any parameter besides the path. Example:

 r fylesystem C:\User\marlon\Documents\my_file.html


write[w] ✏️

Write to a given file whatever content you provide as the last parameter. It can write to any 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 connector filesystem, you don't need to provide any parameter besides the path. Example:

 w fylesystem C:\User\marlon\Documents\photo.png


delete[d] 💥

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 connector filesystem, you don't need to provide any parameter besides the path. Example:

 d fylesystem C:\User\marlon\Documents\photo.png