Report abuse

	public static InputStream httpGET(String inURL) throws IOException {
		URLConnection conn = null;
		URL url = new URL(inURL);
		conn = url.openConnection();
		return conn.getInputStream();
	}
public static void writeToFile(InputStream input, File inFile) throws IOException {
		// Throw an exception if there is a problem with the parameters
		if (input == null) {
			throw new IOException("Could not write to file due to null InputStream");
		}
		if (inFile.exists()) {
			input.close();
			throw new IOException("Could not write to file because the following file already existed:"
					+ "\n" + inFile.getCanonicalPath());
		}

		// write the file
		BufferedOutputStream output = null;
		try {
			output = new BufferedOutputStream(new FileOutputStream(inFile));
			byte[] buffer = new byte[1024];
			int numRead;
			long numWritten = 0;
			while ((numRead = input.read(buffer)) != -1) {
				output.write(buffer, 0, numRead);
				numWritten += numRead;
			}
		} finally {
			// close the streams
			if (output != null) {
				output.close();
			}
			input.close();
		}
	}