https://kotlinlang.org logo
Title
j

jfburdet

09/06/2019, 2:35 PM
Hi folks, I'm using kotlin with intellij and gradle, and have weird problem : I can access (build+run) java.io.InputStream.readAllBytes() in the IDE, but when running the project with gradle, i'm getting an "Unresolved reference: readAllBytes" readAllBytes seems included in Java12 but not in Java1.8 ... Any quick hint ? I can provide a sample project to reproduce that ...
u

Uzi Landsmann

09/06/2019, 2:42 PM
InputStream.readAllBytes()
was added in java 9. Which java version are you using when running gradle?
c

christophsturm

09/06/2019, 2:45 PM
j

jfburdet

09/06/2019, 3:26 PM
@Uzi Landsmann In not sure on to specify in gradle to use Java12 ?
u

Uzi Landsmann

09/06/2019, 3:29 PM
Gradle uses whatever is defined in your JAVA_HOME.
j

jfburdet

09/06/2019, 3:31 PM
@Uzi Landsmann It makes sense. My environnement defaults to java-8-opensdk ... I'll tweak that and it should be ok.
👍 1
(confirmed : on archlinux, "sudo archlinux-java set java-12-openjdk" solved my problem. Thx !)
c

christophsturm

09/06/2019, 3:53 PM
if you just use the kotlin method instead your code will also work with 1.8
j

jfburdet

09/06/2019, 6:02 PM
@christophsturm Yes, but my code was about to read all bytes of a DigestInputStream to calculate some sha-256 hash.
(and not a File)
c

christophsturm

09/06/2019, 6:03 PM
I think there’s also a method for input stream