Free Trial
10 days, no credit_card

<< More Tutorials

How to use rethumb in Kotlin?

To use rethumb in Kotlin try the following code:

import java.io.FileOutputStream
import java.net.URL
import java.nio.channels.Channels

object KotlinRethumbGenericExample {

    @Throws(Exception::class)
    @JvmStatic fun main(args: Array<String>) {

        val website = URL("http://api.rethumb.com/v1/width/100/http://factor45.org/images/beach.jpg")

        val rbc = Channels.newChannel(website.openStream())
        val fos = FileOutputStream("beach.thumb.jpg")
        fos.channel.transferFrom(rbc, 0, java.lang.Long.MAX_VALUE)
    }
}

Start using this example now

Use the following commands to get started:

$ git clone https://github.com/rethumb/rethumb-kotlin-examples.git
$ cd rethumb-kotlin-examples
$ kotlinc generic.kt -include-runtime -d generic.jar
$ java -jar generic.jar

More examples using Kotlin