Example usage for java.lang StringBuffer substring

List of usage examples for java.lang StringBuffer substring

Introduction

In this page you can find the example usage for java.lang StringBuffer substring.

Prototype

@Override
public synchronized String substring(int start, int end) 

Source Link

Usage

From source file:org.pentaho.di.core.Const.java

/**
 * Alternate faster version of string replace using a stringbuffer as input.
 *
 * @param str//  w ww.j ava2  s. c  o  m
 *          The string where we want to replace in
 * @param code
 *          The code to search for
 * @param repl
 *          The replacement string for code
 */
public static void repl(StringBuffer str, String code, String repl) {
    int clength = code.length();

    int i = str.length() - clength;

    while (i >= 0) {
        String look = str.substring(i, i + clength);
        // Look for a match!
        if (look.equalsIgnoreCase(code)) {
            str.replace(i, i + clength, repl);
        }
        i--;
    }
}

From source file:org.etudes.component.app.melete.SectionDB.java

public void deleteResources(Session session, List<String> delResources, boolean removeResourceFlag) {
    StringBuffer delResourceIds = new StringBuffer("(");
    // delete melete resource
    for (String delRes : delResources) {
        if (delRes == null)
            continue;
        delResourceIds.append("'" + delRes + "',");
        if (removeResourceFlag == true) {
            try {
                meleteCHService.removeResource(delRes);
            } catch (Exception e) {
                logger.warn("unable to delete resource.its still asociated with section." + delRes);
            }//from  w ww  .j a v  a  2  s.  co  m
        }
    }

    if (delResourceIds.lastIndexOf(",") != -1)
        delResourceIds = new StringBuffer(delResourceIds.substring(0, delResourceIds.lastIndexOf(",")) + " )");

    String delMeleteResourceStr = "delete MeleteResource mr where mr.resourceId in " + delResourceIds;
    int deletedEntities = session.createQuery(delMeleteResourceStr).executeUpdate();
}

From source file:org.sakaiproject.signup.tool.downloadEvents.EventWorksheet.java

private String getAvailableSitesGroups(SignupMeeting sm) {
    StringBuffer sb = new StringBuffer();
    List<SignupSite> sites = sm.getSignupSites();
    for (SignupSite site : sites) {
        sb.append(site.getTitle());//from   ww  w  .j a va  2 s  .  c o m
        if (site.isSiteScope()) {
            sb.append(" " + rb.getString("event_site_level"));
            sb.append("\n");
            continue;
        }

        sb.append(" " + rb.getString("event_group_level"));
        sb.append("\n");
        List<SignupGroup> groups = site.getSignupGroups();
        if (groups != null) {
            for (SignupGroup grp : groups) {
                sb.append("   - " + grp.getTitle());
                sb.append("\n");
            }
        }

    }
    /* remove the last'\n' one */
    return sb.length() > 1 ? sb.substring(0, sb.length() - 1) : "";
}

From source file:gobblin.service.FlowStatusResource.java

/**
 * Forms a {@link gobblin.service.FlowStatus} from a {@link gobblin.service.monitoring.FlowStatus}
 * @param monitoringFlowStatus//from   w w w .  j  ava2 s . c o  m
 * @return a {@link gobblin.service.FlowStatus} converted from a {@link gobblin.service.monitoring.FlowStatus}
 */
private FlowStatus convertFlowStatus(gobblin.service.monitoring.FlowStatus monitoringFlowStatus) {
    if (monitoringFlowStatus == null) {
        return null;
    }

    Iterator<gobblin.service.monitoring.JobStatus> jobStatusIter = monitoringFlowStatus.getJobStatusIterator();
    JobStatusArray jobStatusArray = new JobStatusArray();
    FlowId flowId = new FlowId().setFlowName(monitoringFlowStatus.getFlowName())
            .setFlowGroup(monitoringFlowStatus.getFlowGroup());
    long flowStartTime = Long.MAX_VALUE;
    long flowEndTime = -1L;
    // flow execution status is complete unless job status indicates it is running or failed
    ExecutionStatus flowExecutionStatus = ExecutionStatus.COMPLETE;
    StringBuffer flowMessagesStringBuffer = new StringBuffer();

    while (jobStatusIter.hasNext()) {
        gobblin.service.monitoring.JobStatus queriedJobStatus = jobStatusIter.next();
        JobStatus jobStatus = new JobStatus();

        jobStatus.setFlowId(flowId)
                .setJobId(new JobId().setJobName(queriedJobStatus.getJobName())
                        .setJobGroup(queriedJobStatus.getJobGroup()))
                .setExecutionStatistics(
                        new JobStatistics().setExecutionStartTime(queriedJobStatus.getStartTime())
                                .setExecutionEndTime(queriedJobStatus.getEndTime())
                                .setProcessedCount(queriedJobStatus.getProcessedCount()))
                .setExecutionStatus(timingEventToStatus(queriedJobStatus.getEventName()))
                .setMessage(queriedJobStatus.getMessage())
                .setJobState(new JobState().setLowWatermark(queriedJobStatus.getLowWatermark())
                        .setHighWatermark(queriedJobStatus.getHighWatermark()));

        jobStatusArray.add(jobStatus);

        if (queriedJobStatus.getStartTime() < flowStartTime) {
            flowStartTime = queriedJobStatus.getStartTime();
        }

        // TODO: end time should be left as -1 if not all jobs have started for the flow
        // need to have flow job count to determine this
        if (queriedJobStatus.getEndTime() > flowEndTime) {
            flowEndTime = queriedJobStatus.getEndTime();
        }

        if (!queriedJobStatus.getMessage().isEmpty()) {
            flowMessagesStringBuffer.append(queriedJobStatus.getMessage());
            flowMessagesStringBuffer.append(MESSAGE_SEPARATOR);
        }

        flowExecutionStatus = updatedFlowExecutionStatus(jobStatus.getExecutionStatus(), flowExecutionStatus);
    }

    String flowMessages = flowMessagesStringBuffer.length() > 0 ? flowMessagesStringBuffer.substring(0,
            flowMessagesStringBuffer.length() - MESSAGE_SEPARATOR.length()) : StringUtils.EMPTY;

    return new FlowStatus()
            .setId(new FlowStatusId().setFlowGroup(flowId.getFlowGroup()).setFlowName(flowId.getFlowName())
                    .setFlowExecutionId(monitoringFlowStatus.getFlowExecutionId()))
            .setExecutionStatistics(
                    new FlowStatistics().setExecutionStartTime(flowStartTime).setExecutionEndTime(flowEndTime))
            .setMessage(flowMessages).setExecutionStatus(flowExecutionStatus).setJobStatuses(jobStatusArray);
}

From source file:org.apache.gobblin.service.FlowStatusResource.java

/**
 * Forms a {@link org.apache.gobblin.service.FlowStatus} from a {@link org.apache.gobblin.service.monitoring.FlowStatus}
 * @param monitoringFlowStatus//from   ww  w .j  a v a 2 s  .c o m
 * @return a {@link org.apache.gobblin.service.FlowStatus} converted from a {@link org.apache.gobblin.service.monitoring.FlowStatus}
 */
private FlowStatus convertFlowStatus(org.apache.gobblin.service.monitoring.FlowStatus monitoringFlowStatus) {
    if (monitoringFlowStatus == null) {
        return null;
    }

    Iterator<org.apache.gobblin.service.monitoring.JobStatus> jobStatusIter = monitoringFlowStatus
            .getJobStatusIterator();
    JobStatusArray jobStatusArray = new JobStatusArray();
    FlowId flowId = new FlowId().setFlowName(monitoringFlowStatus.getFlowName())
            .setFlowGroup(monitoringFlowStatus.getFlowGroup());
    long flowStartTime = Long.MAX_VALUE;
    long flowEndTime = -1L;
    // flow execution status is complete unless job status indicates it is running or failed
    ExecutionStatus flowExecutionStatus = ExecutionStatus.COMPLETE;
    StringBuffer flowMessagesStringBuffer = new StringBuffer();

    while (jobStatusIter.hasNext()) {
        org.apache.gobblin.service.monitoring.JobStatus queriedJobStatus = jobStatusIter.next();
        JobStatus jobStatus = new JobStatus();

        jobStatus.setFlowId(flowId)
                .setJobId(new JobId().setJobName(queriedJobStatus.getJobName())
                        .setJobGroup(queriedJobStatus.getJobGroup()))
                .setExecutionStatistics(
                        new JobStatistics().setExecutionStartTime(queriedJobStatus.getStartTime())
                                .setExecutionEndTime(queriedJobStatus.getEndTime())
                                .setProcessedCount(queriedJobStatus.getProcessedCount()))
                .setExecutionStatus(timingEventToStatus(queriedJobStatus.getEventName()))
                .setMessage(queriedJobStatus.getMessage())
                .setJobState(new JobState().setLowWatermark(queriedJobStatus.getLowWatermark())
                        .setHighWatermark(queriedJobStatus.getHighWatermark()));

        jobStatusArray.add(jobStatus);

        if (queriedJobStatus.getStartTime() < flowStartTime) {
            flowStartTime = queriedJobStatus.getStartTime();
        }

        // TODO: end time should be left as -1 if not all jobs have started for the flow
        // need to have flow job count to determine this
        if (queriedJobStatus.getEndTime() > flowEndTime) {
            flowEndTime = queriedJobStatus.getEndTime();
        }

        if (!queriedJobStatus.getMessage().isEmpty()) {
            flowMessagesStringBuffer.append(queriedJobStatus.getMessage());
            flowMessagesStringBuffer.append(MESSAGE_SEPARATOR);
        }

        flowExecutionStatus = updatedFlowExecutionStatus(jobStatus.getExecutionStatus(), flowExecutionStatus);
    }

    String flowMessages = flowMessagesStringBuffer.length() > 0 ? flowMessagesStringBuffer.substring(0,
            flowMessagesStringBuffer.length() - MESSAGE_SEPARATOR.length()) : StringUtils.EMPTY;

    return new FlowStatus()
            .setId(new FlowStatusId().setFlowGroup(flowId.getFlowGroup()).setFlowName(flowId.getFlowName())
                    .setFlowExecutionId(monitoringFlowStatus.getFlowExecutionId()))
            .setExecutionStatistics(
                    new FlowStatistics().setExecutionStartTime(flowStartTime).setExecutionEndTime(flowEndTime))
            .setMessage(flowMessages).setExecutionStatus(flowExecutionStatus).setJobStatuses(jobStatusArray);
}

From source file:org.kchine.r.server.manager.ServerManager.java

public static RServices createRSsh(boolean keepAlive, String codeServerHostIp, int codeServerPort,
        Properties namingInfo, int memoryMinMegabytes, int memoryMaxMegabytes, String sshHostIp, int sshPort,
        String sshLogin, String sshPwd, String name, boolean showProgress, URL[] codeUrls, String logFile)
        throws BadSshHostException, BadSshLoginPwdException, Exception {

    if (showProgress) {
        createRSshProgressArea = new JTextArea();
        createRSshProgressBar = new JProgressBar(0, 100);
        createRSshProgressFrame = new JFrame("Create R Server via SSH");

        Runnable runnable = new Runnable() {
            public void run() {
                createRSshProgressArea.setFocusable(false);
                createRSshProgressBar.setIndeterminate(true);
                JPanel p = new JPanel(new BorderLayout());
                p.add(createRSshProgressBar, BorderLayout.SOUTH);
                p.add(new JScrollPane(createRSshProgressArea), BorderLayout.CENTER);
                createRSshProgressFrame.add(p);
                createRSshProgressFrame.pack();
                createRSshProgressFrame.setSize(300, 90);
                createRSshProgressFrame.setVisible(true);
                createRSshProgressFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
                PoolUtils.locateInScreenCenter(createRSshProgressFrame);
            }/*from w  w w.  j a v  a 2 s  .  c  o  m*/
        };

        if (SwingUtilities.isEventDispatchThread())
            runnable.run();
        else {
            SwingUtilities.invokeLater(runnable);
        }
    }

    Connection conn = null;
    try {
        conn = new Connection(sshHostIp, sshPort);
        try {
            conn.connect();
        } catch (Exception e) {
            throw new BadSshHostException();
        }
        boolean isAuthenticated = conn.authenticateWithPassword(sshLogin, sshPwd);
        if (isAuthenticated == false)
            throw new BadSshLoginPwdException();

        InputStream is = ServerManager.class
                .getResourceAsStream("/org/kchine/r/server/manager/bootstrap/BootSsh.class");
        byte[] buffer = new byte[is.available()];
        try {
            for (int i = 0; i < buffer.length; ++i) {
                int b = is.read();
                buffer[i] = (byte) b;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        String bootstrapDir = INSTALL_DIR + "classes/org/kchine/r/server/manager/bootstrap";
        new File(bootstrapDir).mkdirs();
        RandomAccessFile raf = new RandomAccessFile(bootstrapDir + "/BootSsh.class", "rw");
        raf.setLength(0);
        raf.write(buffer);
        raf.close();

        Session sess = null;
        try {
            sess = conn.openSession();
            sess.execCommand("mkdir -p RWorkbench/classes/org/kchine/r/server/manager/bootstrap");
            sess.waitForCondition(ChannelCondition.EXIT_STATUS, 0);
        } finally {
            try {
                if (sess != null)
                    sess.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        new SCPClient(conn).put(bootstrapDir + "/BootSsh.class",
                "RWorkbench/classes/org/kchine/r/server/manager/bootstrap");
        try {
            sess = conn.openSession();

            String command = "java -classpath RWorkbench/classes org.kchine.r.server.manager.bootstrap.BootSsh"
                    + " " + new Boolean(keepAlive) + " " + codeServerHostIp + " " + codeServerPort + " "
                    + BootSsh.propertiesToString(namingInfo) + " " + "NULL" + " " + memoryMinMegabytes + " "
                    + memoryMaxMegabytes + " " + "System.out" + " "
                    + ((name == null || name.trim().equals("")) ? BootSsh.NO_NAME : name);

            if (codeUrls != null && codeUrls.length > 0) {
                for (int i = 0; i < codeUrls.length; ++i) {
                    command = command + " " + codeUrls[i];
                }
            }

            System.out.println("createRSsh command:" + command);
            sess.execCommand(command);

            InputStream stdout = new StreamGobbler(sess.getStdout());
            final BufferedReader brOut = new BufferedReader(new InputStreamReader(stdout));

            InputStream stderr = new StreamGobbler(sess.getStderr());
            final BufferedReader brErr = new BufferedReader(new InputStreamReader(stderr));
            final StringBuffer sshOutput = new StringBuffer();
            new Thread(new Runnable() {
                public void run() {
                    try {
                        while (true) {
                            String line = brOut.readLine();
                            if (line == null)
                                break;
                            sshOutput.append(line + "\n");
                            System.out.println(line);
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    System.out.println("Out Log Thread Died");
                }
            }).start();

            new Thread(new Runnable() {
                public void run() {
                    try {
                        while (true) {
                            String line = brErr.readLine();
                            if (line == null)
                                break;
                            System.out.println(line);
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    System.out.println("Err Log Thread Died");
                }
            }).start();

            sess.waitForCondition(ChannelCondition.EXIT_STATUS, 0);

            int eIndex = sshOutput.indexOf(BootSsh.STUB_END_MARKER);
            if (eIndex != -1) {
                int bIndex = sshOutput.indexOf(BootSsh.STUB_BEGIN_MARKER);
                String stub = sshOutput.substring(bIndex + BootSsh.STUB_BEGIN_MARKER.length(), eIndex);
                return (RServices) PoolUtils.hexToStub(stub, ServerManager.class.getClassLoader());
            } else {
                return null;
            }

        } finally {
            try {
                if (sess != null)
                    sess.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

    } finally {
        try {
            if (conn != null)
                conn.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (showProgress) {
            createRSshProgressFrame.setVisible(false);
        }
    }
}

From source file:org.wso2.carbon.is.migration.service.v530.MigrationDatabaseCreator.java

/**
 * executes content in SQL script//  w w  w .  j ava2  s . c  o m
 *
 * @return StringBuffer
 * @throws Exception
 */
private void executeSQLScript(String dbscriptName) throws Exception {

    String databaseType = DatabaseCreator.getDatabaseType(this.conn);
    boolean keepFormat = false;
    if ("oracle".equals(databaseType)) {
        delimiter = "/";
    } else if ("db2".equals(databaseType)) {
        delimiter = "/";
    } else if ("openedge".equals(databaseType)) {
        delimiter = "/";
        keepFormat = true;
    }

    StringBuffer sql = new StringBuffer();
    BufferedReader reader = null;

    try {
        InputStream is = new FileInputStream(dbscriptName);
        reader = new BufferedReader(new InputStreamReader(is));
        String line;
        while ((line = reader.readLine()) != null) {
            line = line.trim();
            if (!keepFormat) {
                if (line.startsWith("//")) {
                    continue;
                }
                if (line.startsWith("--")) {
                    continue;
                }
                StringTokenizer st = new StringTokenizer(line);
                if (st.hasMoreTokens()) {
                    String token = st.nextToken();
                    if ("REM".equalsIgnoreCase(token)) {
                        continue;
                    }
                }
            }
            //add the oracle database owner
            if ("oracle".equals(databaseType) && line.contains("databasename :=")) {
                if (dbscriptName.contains(IDENTITY_DB_SCRIPT)) {
                    line = "databasename := '" + ISMigrationServiceDataHolder.getIdentityOracleUser() + "';";
                } else if (dbscriptName.contains(UM_DB_SCRIPT)) {
                    line = "databasename := '" + ISMigrationServiceDataHolder.getUmOracleUser() + "';";
                }
            }
            sql.append(keepFormat ? "\n" : " ").append(line);

            // SQL defines "--" as a comment to EOL
            // and in Oracle it may contain a hint
            // so we cannot just remove it, instead we must end it
            if (!keepFormat && line.indexOf("--") >= 0) {
                sql.append("\n");
            }
            if ((DatabaseCreator.checkStringBufferEndsWith(sql, delimiter))) {
                executeSQL(sql.substring(0, sql.length() - delimiter.length()));
                sql.replace(0, sql.length(), "");
            }
        }
        // Catch any statements not followed by ;
        if (sql.length() > 0) {
            executeSQL(sql.toString());
        }
    } catch (Exception e) {
        log.error("Error occurred while executing SQL script for migrating database", e);
        throw new Exception("Error occurred while executing SQL script for migrating database", e);

    } finally {
        if (reader != null) {
            reader.close();
        }
    }
}

From source file:org.pentaho.di.core.Const.java

/**
 * Sets the first character of each word in upper-case.
 *
 * @param string//w w w  . j a  va  2  s  .c om
 *          The strings to convert to initcap
 * @return the input string but with the first character of each word converted to upper-case.
 */
public static final String initCap(String string) {
    StringBuffer change = new StringBuffer(string);
    boolean new_word;
    int i;
    char lower, upper, ch;

    new_word = true;
    for (i = 0; i < string.length(); i++) {
        lower = change.substring(i, i + 1).toLowerCase().charAt(0); // Lowercase is default.
        upper = change.substring(i, i + 1).toUpperCase().charAt(0); // Uppercase for new words.
        ch = upper;

        if (new_word) {
            change.setCharAt(i, upper);
        } else {
            change.setCharAt(i, lower);
        }

        new_word = false;

        // Cast to (int) is required for extended characters (SB)
        if (!Character.isLetterOrDigit((int) ch) && ch != '_') {
            new_word = true;
        }
    }

    return change.toString();
}

From source file:org.pentaho.di.core.Const.java

/**
 * Replaces environment variables in a string. For example if you set KETTLE_HOME as an environment variable, you can
 * use %%KETTLE_HOME%% in dialogs etc. to refer to this value. This procedures looks for %%...%% pairs and replaces
 * them including the name of the environment variable with the actual value. In case the variable was not set,
 * nothing is replaced!//from   w ww .j av  a  2  s . c o  m
 *
 * @param string
 *          The source string where text is going to be replaced.
 *
 * @return The expanded string.
 * @deprecated use StringUtil.environmentSubstitute(): handles both Windows and unix conventions
 */
@Deprecated
public static final String replEnv(String string) {
    if (string == null) {
        return null;
    }
    StringBuffer str = new StringBuffer(string);

    int idx = str.indexOf("%%");
    while (idx >= 0) {
        // OK, so we found a marker, look for the next one...
        int to = str.indexOf("%%", idx + 2);
        if (to >= 0) {
            // OK, we found the other marker also...
            String marker = str.substring(idx, to + 2);
            String var = str.substring(idx + 2, to);

            if (var != null && var.length() > 0) {
                // Get the environment variable
                String newval = getEnvironmentVariable(var, null);

                if (newval != null) {
                    // Replace the whole bunch
                    str.replace(idx, to + 2, newval);
                    // System.out.println("Replaced ["+marker+"] with ["+newval+"]");

                    // The last position has changed...
                    to += newval.length() - marker.length();
                }
            }

        } else {
            // We found the start, but NOT the ending %% without closing %%
            to = idx;
        }

        // Look for the next variable to replace...
        idx = str.indexOf("%%", to + 1);
    }

    return str.toString();
}

From source file:com.isecpartners.gizmo.HttpResponse.java

public void processResponse(InputStream in) throws FailedRequestException {
    StringBuffer content = new StringBuffer();
    DataInputStream inputStream = new DataInputStream(in);
    ArrayByteList blist = new ArrayByteList();
    String header = null;//www.j a  va 2s .c  o m
    int contentLength = 0;
    boolean isChunked = false;
    String line;
    try {
        line = readline(inputStream);
        while (line != null && !line.equals(ENDL)) {
            content.append(line);
            if (line.toUpperCase().contains(CONTENT_LENGTH)
                    && line.toUpperCase().indexOf(CONTENT_LENGTH) == 0) {
                String value = line.substring(line.indexOf(CONTENT_LENGTH) + CONTENT_LENGTH.length() + 2,
                        line.indexOf('\r'));
                contentLength = Integer.parseInt(value.trim());
            } else if (line.toUpperCase().contains(TRANSFER_ENCODING)) {
                if (line.toUpperCase()
                        .substring(
                                line.toUpperCase().indexOf(TRANSFER_ENCODING) + "Transfer-Encoding:".length())
                        .contains("CHUNKED")) {
                    isChunked = true;
                }
            } else if (line.toUpperCase().contains(CONTENT_ENCODING)) {
                String value = line.substring(line.indexOf(CONTENT_ENCODING) + CONTENT_ENCODING.length() + 2,
                        line.indexOf('\r'));
                value = value.trim();
                if (value.toUpperCase().equals("GZIP")) {
                    this.gzip = true;
                } else if (value.toUpperCase().equals("DEFLATE")) {
                    this.deflate = true;
                }
            }
            line = readline(inputStream);
        }
        if (line == null) {
            GizmoView.log(content.toString());
            throw new FailedRequestException();
        }

        content.append("\r\n");
        header = content.substring(0, content.indexOf("\r\n"));
        append(blist, content);

        if (contentLength != 0) {
            for (int ii = 0; ii < contentLength; ii++) {
                blist.add(inputStream.readByte());
            }
        }

        if (isChunked) {
            boolean isDone = false;
            while (!isDone) {
                byte current = inputStream.readByte();
                blist.add(current);

                int size = 0;
                while (current != '\n') {
                    if (current != '\r') {
                        size *= 16;
                        if (Character.isLetter((char) current)) {
                            current = (byte) Character.toLowerCase((char) current);
                        }
                        if ((current >= '0') && (current <= '9')) {
                            size += (current - 48);
                        } else if ((current >= 'a') && (current <= 'f')) {
                            size += (10 + current - 97);
                        }
                    }
                    current = inputStream.readByte();

                    while ((char) current == ' ') {
                        current = inputStream.readByte();
                    }
                    blist.add(current);
                }

                if (size != 0) {
                    for (int ii = 0; ii < size; ii++) {
                        int byte1 = inputStream.readByte();
                        byte blah = (byte) byte1;
                        blist.add(blah);
                    }
                    blist.add(inputStream.readByte());
                    blist.add(inputStream.readByte());
                } else {
                    byte ch = (byte) inputStream.read();
                    StringBuffer endstuff = new StringBuffer();
                    blist.add(ch);
                    endstuff.append((char) ch);
                    while (ch != '\n') {
                        ch = inputStream.readByte();
                        endstuff.append((char) ch);
                        blist.add(ch);
                    }

                    isDone = true;
                }

            }
        }

        if (inputStream.available() > 0) {
            try {
                while (true) {
                    blist.add(inputStream.readByte());
                }
            } catch (EOFException e) {
                System.out.println(e);
            }
        }
    } catch (IOException ex) {
        Logger.getLogger(HttpResponse.class.getName()).log(Level.SEVERE, null, ex);
    }

    setBlist(blist);
    setHeader(header);
    if (this.gzip) {
        addContents(unzipData(blist.toArray()));
    } else if (this.deflate) {
        addContents(deflateData(blist.toArray()));
    } else {
        addContents(content.toString());
    }
}