Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

jcon: Java connector to remote filesystem (remote file access in Java)

License

NotificationsYou must be signed in to change notification settings

marlonrcfranco/jcon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub release (latest by date)Build StatusGitHub repo sizeGitHub top languageGitHubGitHub 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 theJcon class.

importcom.marlonrcfranco.Jcon;


List all files and directories in a given path: 📂

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");


Read contents of a file: 📃

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");


Write contents to a file: ✏️

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);


Delete a file or directory: 💥

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");


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 remotelylist,read,write ordelete files and directories.


help[h] 🤔

If you need some help, just typehelp orh


connectors[c] 🔌

For a quick info about the supported protocols, just typeconnectors orc


list[l] 📂

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[r] 📃

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[w] ✏️

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

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


[8]ページ先頭

©2009-2025 Movatter.jp