JVM Network Utils
Utilities used to manage network actions in JVM (Java Virtual Machine).
Feature status
-
โ๏ธ Complete -
๐ณ Partial complete -
๐ฒ Incomplete
Features
- Make Http request
-
โ๏ธ GET-
โ๏ธ Sync -
โ๏ธ Async -
โ๏ธ Coroutines
-
-
โ๏ธ POST-
โ๏ธ Sync -
โ๏ธ Async -
โ๏ธ Coroutines
-
-
โ๏ธ PUT-
โ๏ธ Sync -
โ๏ธ Async -
โ๏ธ Coroutines
-
- PATCH
- Sync
- Async
- Coroutines
-
โ๏ธ DELETE-
โ๏ธ Sync -
โ๏ธ Async -
โ๏ธ Coroutines
-
-
- Download resources from server
-
โ๏ธ Get percentage of download -
โ๏ธ Calculate file size -
โ๏ธ Real time download status -
โ๏ธ Cancel download -
๐ณ Pause download (Partial)- Resume download
-
-
๐ณ Upload files to server- Get percentage of upload
- Calculate time
- Real time download status
Problems
It's not possible to upload large files. I'm working to fix this problem. If you know how to upload large files by chunks you can fork this repo and make a pull request.
Any help is good.
๐
๐
Download
You can download jar file from Release section or put in your gradle project the next code:
Groovy DSL
repositories {
mavenCentral()
}
dependencies {
implementation "com.github.ushiosan23:networkutils:0.0.4"
}
Kotlin DSL
repositories {
mavenCentral()
}
dependencies {
implementation("com.github.ushiosan23:networkutils:0.0.4")
}
Maven POM File
<dependencies>
<dependency>
<groupId>com.github.ushiosan23</groupId>
<artifactId>networkutils</artifactId>
<version>0.0.4</version>
</dependency>
</dependencies>
How to use
Simple http request
- Java
import com.github.ushiosan23.networkutils.http.HttpRequestAction;
class SimpleHttpRequest {
HttpRequestAction action = new HttpRequestAction("https://api.github.com/users/Ushiosan23");
// Create asynchronous request
public void makeSyncRequest() throws Exception {
System.out.println(action.get().body());
}
// Create asynchronous request
public void makeAsyncRequest() {
// Action always return the same action
action.getAsync(action -> {
System.out.println(action.body());
return action;
});
}
public static void main(String[] args) throws Exception {
SimpleHttpRequest request = new SimpleHttpRequest();
request.makeAsyncRequest();
request.makeSyncRequest();
Thread.sleep(5000);
}
}
- Kotlin
import com.github.ushiosan23.networkutils.http.HttpRequestAction
fun main() {
val request = HttpRequestAction("https://api.github.com/users/Ushiosan23")
// Asynchronous request
request.getAsync { action ->
println(action.body())
return@getAsync action
}
// Synchronous request
println(request.get().body())
Thread.sleep(5000)
}
- Kotlin Coroutines
import com.github.ushiosan23.networkutils.http.HttpRequestAction
import com.github.ushiosan23.networkutils.http.getAsyncC
suspend fun main() {
val request = HttpRequestAction("https://api.github.com/users/Ushiosan23")
// Asynchronous request with coroutines
println(request.getAsyncC().body())
// Synchronous request
println(request.get().body())
}