Giter VIP home page Giter VIP logo

jcon's Introduction

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

jcon's People

Contributors

marlonrcfranco avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.