Skip to content
Aman Preet Singh edited this page Feb 17, 2018 · 9 revisions

HOW TO USE?

  1. Download the .jar and include in your build folder. Add the FileRWLibrary.jar to your project build library(on Eclipse and Netbeans).

    NOTE: Every IDE has a bit different way to add .jar and .zip to build directory. Please refer to IDE help or Google for the same.

  2. Import the required package/class and you are good to use them in your code.


List of methods and their parameters.

List of frequently used parameters.

-> String filename : Name of the file with extension.

-> String path : path of folder containing file provided(without last "")

-> int dec_type : Type of decryption. Dec_type is '1' if file is encrypted and '2' if plain text.

-> int start : Line number to start block reading from.

-> int end : Line number to end block reading.

-> int count : number of lines to read.'

-> String text : text to search for to include or exclude.

-> String key : 16 character key for custom decryption.

-> String data : String or text to write to file.

-> String data[] : String array or multiline text to write to file.

-> Boolean append : "True" to write to next line and "false" to write continuously.

-> int enc_type : 1 for encryption, 2 for plain text.

-> String old_data : Text to look for

-> String new_data : Text to replace old_data with.

-> int mode : 1 or DELETE for only removal of old_text, 2 or UPDATE for overwriting of old_text with new_text.

Package "readlib"

-> class "Reader"

--> method : countLines(Filename, path); Returns count of lines otherwise 0.

--> method : readAll(filename, path, dec_type); Returns String array if records exist otherwise nothing

--> method : readBlock(start, end, filename, path, dec_type); Returns String array if records exist otherwise nothing

--> method : readFirstn(count filename, path, dec_type); Returns String array if records exist otherwise nothing

--> method : readLastn(count, filename, path, dec_type); Returns String array if records exist otherwise nothing

--> method : readFilterInc(text, filename, path, dec_type); Returns String array if records exist otherwise nothing

--> method : readFilterExc(text, filename, path, dec_type); Returns String array if records exist otherwise nothing

NOTE: All these methods have overridden verison with "KEY" as added parameter to use for decryption if custom encryption is used while writing.

Package "security"

-> class EncDec

**Default encryption key is TOMMARVOLORIDDLE **

--> method : encrypt(text); Returns encrypted text(AES-128)

--> method : decrypt(text); Returns decrypted text(AES-128)

--> method : encrypt(text, key); Returns encrypted text(AES-128) with custom key.

--> method : decrypt(text, key); Returns decrypted text(AES-128) with custom key.

Package "setup"

-> class SetupManager

--> method : createFolder(foldername, path); To create a folder.

--> method : removeFolder(foldername, path); To remove an empty folder.

--> method : removeFolder_contents(foldername, path); To delete entire directory.

--> method : createFile(filename, path); To create a new file

--> method : removeFile(filename, path); To delete a file

--> method : rename(filename, path, new_name); Renames both files and folders.

--> method : getDir(String); Returns most used paths.

  • "home" - Home Directory
  • "documents" - Documents
  • "downloads" - Downloads
  • "desktop" - Desktop
  • "username" - OS username

--> method : backupFolder(target, destination); Makes a copy of entire folder and its sub-folders to destination.

Package "writelib"

-> class Writer

--> method : writeData_Single(filename, path, data, append, enc_type); Writes the line to file.

--> method : writeData_Block(filename, path, data[], append, enc_type); Writes entire block to file.

--> method : overwrite_Line(filename, path, old_data, new_data, enc_type, mode); Overwrites or removes the line.

NOTE: All these methods have overridden verison with "KEY" as added parameter to use for encryption if custom encryption is required.

--> method : clearFile(filename, path); Removes all data from the file.