babashka/test-resources/bytechannel_and_related_classes.bb
Michiel Borkent bf183a33a8
Add bytechannel + more tests (#1706)
Co-authored-by: Jarppe <jarppe@metosin.fi>
2024-06-18 09:08:12 +02:00

22 lines
1 KiB
Clojure

(ns bytechannel-and-related-classes
(:require [clojure.java.io :as io])
(:import (java.nio.file OpenOption
StandardOpenOption)
(java.nio.channels ByteChannel
FileChannel
ReadableByteChannel
WritableByteChannel
Channels)))
(when (and (let [ch (-> (.getBytes "Hello")
(java.io.ByteArrayInputStream.)
(Channels/newChannel))]
(instance? ReadableByteChannel ch))
(let [ch (-> (java.io.ByteArrayOutputStream.)
(Channels/newChannel))]
(instance? WritableByteChannel ch))
(with-open [ch (FileChannel/open (-> (io/file "README.md")
(.toPath))
(into-array OpenOption [StandardOpenOption/READ]))]
(instance? ByteChannel ch)))
(println :success))