Java HTTP Read readHttpConnection(HttpURLConnection h)

Here you can find the source of readHttpConnection(HttpURLConnection h)

Description

read Http Connection

License

Open Source License

Declaration

public static byte[] readHttpConnection(HttpURLConnection h)
            throws IOException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.IOException;
import java.io.InputStream;

import java.net.HttpURLConnection;

import java.util.ArrayList;

public class Main {
    public static byte[] readHttpConnection(HttpURLConnection h)
            throws IOException {
        ArrayList<Byte> a = new ArrayList<Byte>(100);
        InputStream is = h.getInputStream();
        int i = is.read();
        while (i != -1) {
            a.add((byte) i);
            i = is.read();//from ww  w  . j a va2 s  .co m
        }
        byte b[] = new byte[a.size()];
        i = 0;
        for (Byte y : a) {
            b[i++] = y;
        }
        return b;
    }
}

Related

  1. getResult(String urlStr, String content)
  2. readData(HttpURLConnection conn)
  3. readError(HttpURLConnection conn)
  4. readGetEx(String url)
  5. readHTTPConnection(HttpURLConnection conn)
  6. readHttpFile(String fileUrl, String referer)
  7. readRaw(URL url)