Code example for ByteArrayEntity

Methods: setContentType

0
            StringBuffer buf = new StringBuffer("<html><head><title>");
            buf.append(reason);
            buf.append("</title></head><body>");
            buf.append(reason);
            buf.append("</body></html>");
            response.setEntity(createEntity(buf.toString().getBytes()));
        } 
        return response;
    } 
 
    /** 
     * Create a string entity for the given content. 
     */ 
    private ByteArrayEntity createEntity(byte[] data) {
        ByteArrayEntity entity = new ByteArrayEntity(data);
        entity.setContentType("text/html");
        return entity;
    } 
 
    private static class ServerThread extends Thread {
        private TestWebServer mServer;
Connect your IDE to all the code out there  Get Codota for Java