2 import "JavaBuiltin" as Java
4 class Closeable a where
5 close :: a -> <Proc> ()
9 importJava "java.io.InputStream" where
14 closeInputStream :: InputStream -> <Proc> ()
15 skip :: InputStream -> Long -> <Proc> Long
17 instance Closeable InputStream where
18 close = closeInputStream
22 importJava "java.io.OutputStream" where
27 closeOutputStream :: OutputStream -> <Proc> ()
29 instance Closeable OutputStream where
30 close = closeOutputStream
34 class Writable a where
35 openForWriting :: a -> <Proc> OutputStream
37 class Readable a where
38 openForReading :: a -> <Proc> InputStream
42 importJava "java.io.ByteArrayInputStream" where
45 openArrayForReading :: ByteArray -> <Proc> InputStream
47 instance Readable ByteArray where
48 openForReading = openArrayForReading
50 importJava "java.io.ByteArrayOutputStream" where
54 createBuffer :: () -> <Proc> Buffer
55 toByteArray :: Buffer -> <Proc> ByteArray
57 instance Writable Buffer where
58 openForWriting = Java.unsafeCoerce