Mercurial Hosting > luan
comparison core/src/luan/modules/IoLuan.java @ 745:9c1f28b26395
a uri can now write another uri which copies the content
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Wed, 13 Jul 2016 21:27:23 -0600 |
| parents | 4b8695f1cfc4 |
| children | 293c397e8dee |
comparison
equal
deleted
inserted
replaced
| 744:4b8695f1cfc4 | 745:9c1f28b26395 |
|---|---|
| 286 OutputStream out = outputStream(); | 286 OutputStream out = outputStream(); |
| 287 Utils.copyAll(new ByteArrayInputStream(a),out); | 287 Utils.copyAll(new ByteArrayInputStream(a),out); |
| 288 out.close(); | 288 out.close(); |
| 289 return; | 289 return; |
| 290 } | 290 } |
| 291 throw new LuanException( "bad argument #1 to 'write' (string or binary expected)" ); | 291 if( obj instanceof LuanTable ) { |
| 292 LuanTable t = (LuanTable)obj; | |
| 293 Object java = t.rawGet("java"); | |
| 294 if( java instanceof LuanIn ) { | |
| 295 LuanIn luanIn = (LuanIn)java; | |
| 296 InputStream in = luanIn.inputStream(); | |
| 297 OutputStream out = outputStream(); | |
| 298 Utils.copyAll(in,out); | |
| 299 out.close(); | |
| 300 in.close(); | |
| 301 return; | |
| 302 } | |
| 303 } | |
| 304 throw new LuanException( "bad argument #1 to 'write' (string or binary or Io.uri expected)" ); | |
| 292 } | 305 } |
| 293 | 306 |
| 294 public LuanTable text_writer() throws IOException { | 307 public LuanTable text_writer() throws IOException { |
| 295 return textWriter(new BufferedWriter(new OutputStreamWriter(outputStream()))); | 308 return textWriter(new BufferedWriter(new OutputStreamWriter(outputStream()))); |
| 296 } | 309 } |
