Mercurial Hosting > luan
comparison src/luan/modules/Utils.java @ 1493:471ef3e6a84e
more io
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 03 May 2020 00:12:15 -0600 |
parents | 225808b90cee |
children | 0ba144491a42 |
comparison
equal
deleted
inserted
replaced
1492:aaac1d29edea | 1493:471ef3e6a84e |
---|---|
8 import java.io.File; | 8 import java.io.File; |
9 import java.io.InputStreamReader; | 9 import java.io.InputStreamReader; |
10 import java.net.URL; | 10 import java.net.URL; |
11 import java.net.MalformedURLException; | 11 import java.net.MalformedURLException; |
12 import java.util.Map; | 12 import java.util.Map; |
13 import goodjava.io.IoUtils; | |
13 import luan.Luan; | 14 import luan.Luan; |
14 import luan.LuanException; | 15 import luan.LuanException; |
15 import luan.LuanTable; | 16 import luan.LuanTable; |
16 import luan.LuanFunction; | 17 import luan.LuanFunction; |
17 | 18 |
76 buf.append(a,0,n); | 77 buf.append(a,0,n); |
77 } | 78 } |
78 return buf.toString(); | 79 return buf.toString(); |
79 } | 80 } |
80 | 81 |
81 public static void copyAll(InputStream in,OutputStream out) | |
82 throws IOException | |
83 { | |
84 byte[] a = new byte[bufSize]; | |
85 int n; | |
86 while( (n=in.read(a)) != -1 ) { | |
87 out.write(a,0,n); | |
88 } | |
89 } | |
90 | |
91 public static byte[] readAll(InputStream in) | 82 public static byte[] readAll(InputStream in) |
92 throws IOException | 83 throws IOException |
93 { | 84 { |
94 ByteArrayOutputStream out = new ByteArrayOutputStream(); | 85 ByteArrayOutputStream out = new ByteArrayOutputStream(); |
95 copyAll(in,out); | 86 IoUtils.copyAll(in,out); |
96 return out.toByteArray(); | 87 return out.toByteArray(); |
97 } | 88 } |
98 | 89 |
99 | 90 |
100 public static String removeString(LuanTable options,String key) throws LuanException { | 91 public static String removeString(LuanTable options,String key) throws LuanException { |