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;
try
{
br = new BufferedReader(new InputStreamReader(response, "UTF-8"));
- return parseJSON(br);
+ return new JSONParser().parse(br);
} finally
{
if (br != null)
}
+ /**
+ * 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();
+ }
+ }
+
}