public static void writeFromInputStream(InputStream in, String filePath)
			throws IOException {
		FileOutputStream fos = new FileOutputStream(new File(filePath));
		FileChannel fc = fos.getChannel();
		ReadableByteChannel rbc = Channels.newChannel(in);
		ByteBuffer buffer = ByteBuffer.allocate(BUFFER_SIZE);
		while (true) {
			int count = rbc.read(buffer);
			if (count == -1) {
				break;
			}
			buffer.flip();
			fc.write(buffer);
			buffer.clear();
		}

		rbc.close();
		fc.close();
		fos.close();
	}