Code example for URLConnection

Methods: getInputStream, setDoInput, setDoOutput

0
 
	public static String getJSONLine(URL url) throws IOException {
		BufferedReader in;
 
		URLConnection tc = url.openConnection();
		tc.setDoInput(true);
		tc.setDoOutput(true);
		in = new BufferedReader(new InputStreamReader(tc.getInputStream()));	
		return in.readLine();
	} 
 
	public static byte[] encodeBitmap(Bitmap b)
	{ 
		ByteArrayOutputStream bos = new ByteArrayOutputStream(); 
		b.compress(CompressFormat.PNG, 0 /*ignored for PNG*/, bos); 
		return bos.toByteArray();
	} 
 
 
 
	public static void share(final Promocao promo, final Context c) {