2 import "JavaBuiltin" as Java
4 class Closeable a where
5 close :: a -> <Proc> ()
9 importJava "java.io.InputStream" where
14 closeInputStream :: InputStream -> <Proc> ()
16 instance Closeable InputStream where
17 close = closeInputStream
21 importJava "java.io.OutputStream" where
26 closeOutputStream :: OutputStream -> <Proc> ()
28 instance Closeable OutputStream where
29 close = closeOutputStream
33 class Writable a where
34 openForWriting :: a -> <Proc> OutputStream
36 class Readable a where
37 openForReading :: a -> <Proc> InputStream
41 importJava "java.io.ByteArrayInputStream" where
44 openArrayForReading :: ByteArray -> <Proc> InputStream
46 instance Readable ByteArray where
47 openForReading = openArrayForReading
49 importJava "java.io.ByteArrayOutputStream" where
53 createBuffer :: () -> <Proc> Buffer
54 toByteArray :: Buffer -> <Proc> ByteArray
56 instance Writable Buffer where
57 openForWriting = Java.unsafeCoerce