Giter VIP home page Giter VIP logo

java-utils's Introduction

JavaUtils

CI GitHub Release

JavaUtils is a small library to ease programming with Java.

1. Import

Gradle:

allprojects {
    repositories {
        maven { url 'https://jitpack.io' }
    }
}
dependencies {
    implementation 'com.github.alexsgi:java-utils:VERSION'
}

Maven:

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>com.github.alexsgi</groupId>
        <artifactId>java-utils</artifactId>
        <version>VERSION</version>
    </dependency>
</dependencies>

2. Features

Time-oriented functions :

Run something delayed:

FutureTaskExecutor.runDelayed(Runnable runnable, int delayInMilliSeconds);
FutureTaskExecutor.runDelayed(new Runnable(){
   @Override
   public void run(){
       System.out.println("This message will be printed after 5000 ms");
   }
}, 5000);

FutureTaskExecutor.runDelayed(Runnable runnable, int delayInMilliSeconds, boolean isTerminable);

isTerminable : (default: false) if set to false, the timer will stop properly on finish of the runnable, otherwise (if set to true) the timer can be interrupted (e.g. by the main method).


Cryptography :

SHA2-512:

String sha2_512Hashed = Cryptography.hashSHA2("Example text");

SHA3-512:

String sha3_512Hashed = Cryptography.hashSHA3("Example");

Base64-Encoding:

String base64Encoded = Cryptography.base64Encryption("Example of the example");

Change the hash length (default: 512) :

Cryptography.setHashLength(int hashLength);
Cryptography.setHashLength(256);

Get the hash length :

int hashLength = Cryptography.getHashLength();

Reset the hash length (default: 512) :

Cryptography.resetHashLength();

System :

Get all drives :

Drive[] drives = SystemInfo.getAllDrives();
for(Drive drive : drives){
    System.out.println(drive.getDriveName());
    System.out.println(drive.getDriveLetter());
    System.out.println(drive.getDriveDescription());
}

Color :

Change the text color or even the background color via ANSI codes :

String textFormatted = TextColor.formatColor(String input, String color);
String backgroundFormatted = TextColor.formatBackground(String input, String backgroundColor);
String bothFormated = TextColor.formatColors(String input, String color, String backgroundColor);

Following options are available :

RESET

BLACK
RED
GREEN
YELLOW
BLUE
PURPLE
CYAN
WHITE

BLACK_BACKGROUND
RED_BACKGROUND
GREEN_BACKGROUND
YELLOW_BACKGROUND
BLUE_BACKGROUND
PURPLE_BACKGROUND
CYAN_BACKGROUND
WHITE_BACKGROUND

Example :

TextColor.formatColor("Example", TextColor.CYAN);
TextColor.formatBackground("Example", TextColor.CYAN_BACKGROUND);
TextColor.formatColors("Example", TextColor.CYAN, TextColor.CYAN_BACKGROUND);

UI - Screenshot :

Take a screenshot (PNG):

AdvImage.takeScreenshot(File nameOfTheScreenshot);
File file = new File("C:\\Users\\Public\\Desktop\\screenshot.png");

JPEG screenshots:

AdvImage.takeJPEGScreenshot(File nameOfTheScreenshot);

You want to take multiple screenshots?

AdvImage.takeScrenshots(File path, int amount, int delay);
AdvImage.takeScrenshots(File path, int amount, int delay, boolean inNewThread);

Notice: the input file needs to be a directory


Create many threads with the same runnable :

MultiThreads.createThreads(Runnable runnable, int amountOfThreads);

Start all threads :

MultiThreads.startThreads();

Interrupt all Threads :

MultiThreads.interruptThreads();

Clear all Threads :

MultiThreads.clearThreads();

Get current amount of Threads :

int amount = MultiThreads.getThreadAmount();

Some tools for Strings :

Check if a String contains at least one of the params :

StringUtils.containsOneOf(String src, String... params);

Check if a String contains all of the params :

StringUtils.containsAll(String src, String... params)

java-utils's People

Contributors

alexsgi 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.