X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Futil%2FPlatform.java;h=68985b5ad6315635dbf21b15b4ba7b5f6fe50929;hb=8fa69554edf6aeb278b4a4afd8e2b60264fdccd8;hp=b2bc3f4f4fdf4c307c2aeb80ba81369558f36eea;hpb=2b38dcf01ebc4ac100d99fee946a14c4b18f4693;p=jalview.git diff --git a/src/jalview/util/Platform.java b/src/jalview/util/Platform.java index b2bc3f4..68985b5 100644 --- a/src/jalview/util/Platform.java +++ b/src/jalview/util/Platform.java @@ -26,6 +26,7 @@ import java.awt.Toolkit; import java.awt.event.MouseEvent; import java.io.BufferedReader; import java.io.File; +import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; @@ -463,7 +464,7 @@ public class Platform try { br = new BufferedReader(new InputStreamReader(response, "UTF-8")); - return parseJSON(br); + return new JSONParser().parse(br); } finally { if (br != null) @@ -508,4 +509,38 @@ public class Platform } + /** + * Dump the input stream to an output file. + * + * @param is + * @param outFile + * @throws IOException + * if the file cannot be created or there is a problem reading the + * input stream. + */ + public static void streamToFile(InputStream is, File outFile) + throws IOException + { + if (!isJS() || /** + * @j2sNative outFile.setBytes$O && outFile.setBytes$O(is) || + */ + false) + { + return; + } + FileOutputStream fio = new FileOutputStream(outFile); + try + { + byte[] bb = new byte[32 * 1024]; + int l; + while ((l = is.read(bb)) > 0) + { + fio.write(bb, 0, l); + } + } finally + { + fio.close(); + } + } + }