- ((ByteStream)args.elementAt(1)).writeTo(new FileOutputStream(file));
- return null;
- } catch (IOException e) {
- if (Log.on) Log.log(ByteStream.class, "IO Exception while writing a ByteStream to a file");
- if (Log.on) Log.log(ByteStream.class, e);
- throw new JS.Exn("error while writing a ByteStream to a file");
- }
- */
-
- } else if (method.equals("saveFileAs")) {
- // FIXME
- /*
- if (checkOnly) return Boolean.TRUE;
- if (args.length() != 2) return null;
- if (!(args.elementAt(1) instanceof ByteStream)) return null;
- String file = args.elementAt(0).toString();
- file = Platform.fileDialog(file, true);
- if (file == null) return null;
- safeFiles.put(Platform.isCaseSensitive() ? file : file.toLowerCase(), new Object());
- try {
- ((ByteStream)args.elementAt(1)).writeTo(new FileOutputStream(file));
+ InputStream is = ((Res)args.elementAt(1)).getInputStream();
+ FileOutputStream out = new FileOutputStream(file);
+ byte[] buffer = new byte[1024 * 16];
+ while(true) {
+ int numread = is.read(buffer, 0, buffer.length);
+ if (numread == -1) break;
+ out.write(buffer, 0, numread);
+ }
+ is.close();
+ out.close();