Example usage for java.io BufferedReader read

List of usage examples for java.io BufferedReader read

Introduction

In this page you can find the example usage for java.io BufferedReader read.

Prototype

public int read() throws IOException 

Source Link

Document

Reads a single character.

Usage

From source file:com.jcraft.weirdx.XColormap.java

static void init(Map<String, Color> table) {
    if (_rgbtxt == null)
        return;//from w w  w .j  av a  2  s  . c  om
    StringBuffer foo = new StringBuffer();
    for (int i = 0; i < _rgbtxt.length; i++) {
        foo.append(_rgbtxt[i]);
    }
    rgbtxt = foo.toString();
    _rgbtxt = null;
    foo = null;

    try {
        InputStream is = new ByteArrayInputStream(RGBTXT.rgbtxt.getBytes());
        //      StreamTokenizer st=new StreamTokenizer(is);
        BufferedReader br = new BufferedReader(new InputStreamReader(is));
        StreamTokenizer st = new StreamTokenizer(br);

        st.ordinaryChar('!');
        //    st.ordinaryChar('\n');
        //    st.ordinaryChar('\t');
        //String token=null;
        char c;
        int r, g, b;
        byte[] buf = new byte[1024];
        while (st.nextToken() != StreamTokenizer.TT_EOF) {
            //System.out.println("type="+st.ttype+", "+st.sval);
            if (st.ttype == '!') {
                //     while((c=(char)is.read())!='\n');
                while ((c = (char) br.read()) != '\n')
                    ;
                continue;
            }
            if (st.ttype == StreamTokenizer.TT_NUMBER) {
                r = (int) st.nval;
                st.nextToken();
                g = (int) st.nval;
                st.nextToken();
                b = (int) st.nval;
                //System.out.print("r, g, b="+r+", "+g+", "+b);
                int i = 0;
                //     while((c=(char)is.read())!='\n'){
                while ((c = (char) br.read()) != '\n') {
                    if (c == '\t')
                        continue;
                    if (c == ' ')
                        continue;
                    if ('A' <= c && c <= 'Z') {
                        c = (char) ('a' + c - 'A');
                    }
                    buf[i] = (byte) c;
                    i++;
                }
                table.put(new String(buf, 0, i), new Color(r, g, b));
                //System.out.println(" -> "+new String(buf, 0, i));
                continue;
            }
        }
        st = null;
        buf = null;
        //    table.put("slategrey", rgbTable.get("slate grey"));
        //    table.put("Black", rgbTable.get("black"));
        //    table.put("White", rgbTable.get("white"));
    } catch (Exception e) {
        //System.out.println(e);
    }
}

From source file:org.apache.jmeter.protocol.http.sampler.WebServiceSampler.java

/**
 * Sample the URL using Apache SOAP driver. Implementation note for myself
 * and those that are curious. Current logic marks the end after the
 * response has been read. If read response is set to false, the buffered
 * reader will read, but do nothing with it. Essentially, the stream from
 * the server goes into the ether./*from  w  ww .j av  a2 s .co m*/
 */
@Override
public SampleResult sample() {
    SampleResult result = new SampleResult();
    result.setSuccessful(false); // Assume it will fail
    result.setResponseCode("000"); // ditto $NON-NLS-1$
    result.setSampleLabel(getName());
    try {
        result.setURL(this.getUrl());
        org.w3c.dom.Element rdoc = createDocument();
        if (rdoc == null) {
            throw new SOAPException("Could not create document", null);
        }
        // set the response defaults
        result.setDataEncoding(ENCODING);
        result.setContentType("text/xml"); // $NON-NLS-1$
        result.setDataType(SampleResult.TEXT);
        result.setSamplerData(fileContents);// WARNING - could be large

        Envelope msgEnv = Envelope.unmarshall(rdoc);
        result.sampleStart();
        SOAPHTTPConnection spconn = null;
        // if a blank HeaderManager exists, try to
        // get the SOAPHTTPConnection. After the first
        // request, there should be a connection object
        // stored with the cookie header info.
        if (this.getHeaderManager() != null && this.getHeaderManager().getSOAPHeader() != null) {
            spconn = (SOAPHTTPConnection) this.getHeaderManager().getSOAPHeader();
        } else {
            spconn = new SOAPHTTPConnection();
        }
        spconn.setTimeout(getTimeoutAsInt());

        // set the auth. thanks to KiYun Roe for contributing the patch
        // I cleaned up the patch slightly. 5-26-05
        if (getAuthManager() != null) {
            if (getAuthManager().getAuthForURL(getUrl()) != null) {
                AuthManager authmanager = getAuthManager();
                Authorization auth = authmanager.getAuthForURL(getUrl());
                spconn.setUserName(auth.getUser());
                spconn.setPassword(auth.getPass());
            } else {
                log.warn("the URL for the auth was null." + " Username and password not set");
            }
        }
        // check the proxy
        String phost = "";
        int pport = 0;
        // if use proxy is set, we try to pick up the
        // proxy host and port from either the text
        // fields or from JMeterUtil if they were passed
        // from command line
        if (this.getUseProxy()) {
            if (this.getProxyHost().length() > 0 && this.getProxyPort() > 0) {
                phost = this.getProxyHost();
                pport = this.getProxyPort();
            } else {
                if (System.getProperty("http.proxyHost") != null
                        || System.getProperty("http.proxyPort") != null) {
                    phost = System.getProperty("http.proxyHost");
                    pport = Integer.parseInt(System.getProperty("http.proxyPort"));
                }
            }
            // if for some reason the host is blank and the port is
            // zero, the sampler will fail silently
            if (phost.length() > 0 && pport > 0) {
                spconn.setProxyHost(phost);
                spconn.setProxyPort(pport);
                if (PROXY_USER.length() > 0 && PROXY_PASS.length() > 0) {
                    spconn.setProxyUserName(PROXY_USER);
                    spconn.setProxyPassword(PROXY_PASS);
                }
            }
        }

        HeaderManager headerManager = this.getHeaderManager();
        Hashtable<String, String> reqHeaders = null;
        if (headerManager != null) {
            int size = headerManager.getHeaders().size();
            reqHeaders = new Hashtable<String, String>(size);
            for (int i = 0; i < size; i++) {
                Header header = headerManager.get(i);
                reqHeaders.put(header.getName(), header.getValue());
            }
        }
        spconn.setMaintainSession(getMaintainSession());
        spconn.send(this.getUrl(), this.getSoapAction(), reqHeaders, msgEnv, null, new SOAPContext());

        @SuppressWarnings("unchecked") // API uses raw types
        final Map<String, String> headers = spconn.getHeaders();
        result.setResponseHeaders(convertSoapHeaders(headers));

        if (this.getHeaderManager() != null) {
            this.getHeaderManager().setSOAPHeader(spconn);
        }

        BufferedReader br = null;
        if (spconn.receive() != null) {
            br = spconn.receive();
            SOAPContext sc = spconn.getResponseSOAPContext();
            // Set details from the actual response
            // Needs to be done before response can be stored
            final String contentType = sc.getContentType();
            result.setContentType(contentType);
            result.setEncodingAndType(contentType);
            int length = 0;
            if (getReadResponse()) {
                StringWriter sw = new StringWriter();
                length = IOUtils.copy(br, sw);
                result.sampleEnd();
                result.setResponseData(sw.toString().getBytes(result.getDataEncodingWithDefault()));
            } else {
                // by not reading the response
                // for real, it improves the
                // performance on slow clients
                length = br.read();
                result.sampleEnd();
                result.setResponseData(JMeterUtils.getResString("read_response_message"), null); //$NON-NLS-1$
            }
            // It is not possible to access the actual HTTP response code, so we assume no data means failure
            if (length > 0) {
                result.setSuccessful(true);
                result.setResponseCodeOK();
                result.setResponseMessageOK();
            } else {
                result.setSuccessful(false);
                result.setResponseCode("999");
                result.setResponseMessage("Empty response");
            }
        } else {
            result.sampleEnd();
            result.setSuccessful(false);
            final String contentType = spconn.getResponseSOAPContext().getContentType();
            result.setContentType(contentType);
            result.setEncodingAndType(contentType);
            result.setResponseData(
                    spconn.getResponseSOAPContext().toString().getBytes(result.getDataEncodingWithDefault()));
        }
        if (br != null) {
            br.close();
        }
        // reponse code doesn't really apply, since
        // the soap driver doesn't provide a
        // response code
    } catch (IllegalArgumentException exception) {
        String message = exception.getMessage();
        log.warn(message);
        result.setResponseMessage(message);
    } catch (SAXException exception) {
        log.warn(exception.toString());
        result.setResponseMessage(exception.getMessage());
    } catch (SOAPException exception) {
        log.warn(exception.toString());
        result.setResponseMessage(exception.getMessage());
    } catch (MalformedURLException exception) {
        String message = exception.getMessage();
        log.warn(message);
        result.setResponseMessage(message);
    } catch (IOException exception) {
        String message = exception.getMessage();
        log.warn(message);
        result.setResponseMessage(message);
    } catch (NoClassDefFoundError error) {
        log.error("Missing class: ", error);
        result.setResponseMessage(error.toString());
    } catch (Exception exception) {
        if ("javax.mail.MessagingException".equals(exception.getClass().getName())) {
            log.warn(exception.toString());
            result.setResponseMessage(exception.getMessage());
        } else {
            log.error("Problem processing the SOAP request", exception);
            result.setResponseMessage(exception.toString());
        }
    } finally {
        // Make sure the sample start time and sample end time are recorded
        // in order not to confuse the statistics calculation methods: if
        //  an error occurs and an exception is thrown it is possible that
        // the result.sampleStart() or result.sampleEnd() won't be called
        if (result.getStartTime() == 0) {
            result.sampleStart();
        }
        if (result.getEndTime() == 0) {
            result.sampleEnd();
        }
    }
    return result;
}

From source file:barrysw19.calculon.icc.ICCInterface.java

public void connect() throws IOException {
    connection = new Socket("chessclub.com", 23);
    doLogin();/*www . ja  va2 s .  c  o m*/
    BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
    out = new PrintStream(connection.getOutputStream());

    send("set level1 1");
    send("set style 12");
    if (!StringUtils.isBlank(iccConfig.getFormula())) {
        send("set formula " + iccConfig.getFormula());
    }
    receiveLevel2(DgCommand.DG_MY_GAME_STARTED, DgCommand.DG_MY_GAME_RESULT, DgCommand.DG_SEND_MOVES,
            DgCommand.DG_MOVE_ALGEBRAIC, DgCommand.DG_MOVE_SMITH, DgCommand.DG_MOVE_TIME,
            DgCommand.DG_MOVE_CLOCK, DgCommand.DG_MSEC);

    setStatus();
    if (iccConfig.isReseek()) {
        reseek();
    }

    Runnable keepAlive = () -> {
        while (alive) {
            send("games *r-e-B-o-M-f-K-w-L-d-z");
            try {
                Thread.sleep(60000);
            } catch (InterruptedException x) {
                // Ignore
            }
        }
    };
    Thread keepAliveThread = new Thread(keepAlive);
    keepAliveThread.setDaemon(true);
    keepAliveThread.start();

    StringBuilder line = new StringBuilder();
    int c;
    try {
        while ((c = reader.read()) != -1) {
            lv1BlockHandler.add((char) c);

            // Ignore CTRL-M, CTRL-G
            if (c == ('M' & 0x1F) || c == ('G' & 0x1F)) {
                continue;
            }
            line.append((char) c);
            if (c == '\n') {
                fireDataReceived(line.toString());
                line.setLength(0);
                continue;
            }
            if (line.length() >= 2 && line.charAt(line.length() - 2) == ('Y' & 0x1F)
                    && line.charAt(line.length() - 1) == ']') {
                fireDataReceived(line.toString());
                line.setLength(0);
            }
        }
    } finally {
        alive = false;
        try {
            reader.close();
            out.close();
        } catch (Exception x) {
            // ignore
        }
    }
}

From source file:com.allblacks.utils.web.HttpUtil.java

/**
 * Gets data from URL as char[] throws {@link RuntimeException} If anything
 * goes wrong/* ww  w.  j  a  va2  s .  c  o  m*/
 * 
 * @return The content of the URL as a char[]
 * @throws java.io.IOException
 */
public char[] postDataAsCharArray(String url, String contentType, String contentName, char[] content)
        throws IOException {

    URLConnection urlc = null;
    OutputStream os = null;
    InputStream is = null;
    CharArrayWriter dat = null;
    BufferedReader reader = null;
    String boundary = "" + new Date().getTime();

    try {
        urlc = new URL(url).openConnection();
        urlc.setDoOutput(true);
        urlc.setRequestProperty(HttpUtil.CONTENT_TYPE,
                "multipart/form-data; boundary=---------------------------" + boundary);

        String message1 = "-----------------------------" + boundary + HttpUtil.BNL;
        message1 += "Content-Disposition: form-data; name=\"nzbfile\"; filename=\"" + contentName + "\""
                + HttpUtil.BNL;
        message1 += "Content-Type: " + contentType + HttpUtil.BNL;
        message1 += HttpUtil.BNL;
        String message2 = HttpUtil.BNL + "-----------------------------" + boundary + "--" + HttpUtil.BNL;

        os = urlc.getOutputStream();
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os, Charset.forName(HttpUtil.UTF_8)));

        writer.write(message1);
        writer.write(content);
        writer.write(message2);
        writer.flush();

        dat = new CharArrayWriter();
        if (urlc.getContentEncoding() != null && urlc.getContentEncoding().equalsIgnoreCase(HttpUtil.GZIP)) {
            is = new GZIPInputStream(urlc.getInputStream());
        } else {
            is = urlc.getInputStream();
        }
        reader = new BufferedReader(new InputStreamReader(is, Charset.forName(HttpUtil.UTF_8)));

        int c;
        while ((c = reader.read()) != -1) {
            dat.append((char) c);
        }
    } catch (IOException exception) {
        throw exception;
    } finally {
        try {
            reader.close();
            os.close();
            is.close();
        } catch (Exception e) {
            // we do not care about this
        }
    }

    return dat.toCharArray();
}

From source file:org.testeditor.fixture.swt.SwtBotFixture.java

/**
 * @param message//from  w  ww . ja  v a 2s . c o m
 *            the message as a string, that should send.
 * @return the result of the call
 * @throws UnknownHostException
 * @throws IOException
 */
private boolean sendMessage(String message) {

    StringBuilder result = new StringBuilder();

    try {
        Socket client = getSocket();

        PrintStream os = new PrintStream(client.getOutputStream(), false, CHARSET_UTF_8);
        os.println(message);
        LOGGER.info("Send message to AUT:" + message);
        os.flush();
        BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream(), CHARSET_UTF_8));

        int c;
        while ((c = in.read()) != -1) {
            result.append((char) c);
        }
        String myMessage = result.toString();
        if (myMessage.indexOf("ERROR ") > -1) {
            LOGGER.error("Fails: " + myMessage);
            throw new RuntimeException("Message: " + message + " fails with: " + myMessage);
        }

        client.close();

    } catch (UnknownHostException e) {
        LOGGER.error("SendMessage Host not Found", e);
    } catch (IOException e) {
        LOGGER.error("Send Message IOException ", e);
    }
    if (result.toString().startsWith("true")) {
        return true;
    }
    return false;
}

From source file:com.wso2telco.dep.reportingservice.northbound.NbHostObjectUtils.java

/**
 * Gets the report.//ww  w.j av  a  2  s.  c  om
 *
 * @param suscriber the suscriber
 * @param period the period
 * @return the report
 */
public static String getReport(String suscriber, String period) {
    String fileContent = "";
    BufferedReader bufferedReader = null;
    try {
        File file = getCSVFile(suscriber, period);
        bufferedReader = new BufferedReader(new FileReader(file));

        StringBuilder fileAppender = new StringBuilder();

        int c = -1;

        while ((c = bufferedReader.read()) != -1) {
            char ch = (char) c;
            fileAppender.append(ch);
        }

        fileContent = fileAppender.toString();

    } catch (IOException e) {
        log.error("report file reading error : " + e.getMessage());
    } finally {
        try {
            bufferedReader.close();
        } catch (IOException e) {
            log.error("Buuffered Reader closing error : " + e.getMessage());
        }
    }
    return fileContent;
}

From source file:be.docarch.odt2braille.PEF.java

/**
 * maxPages: -1 = infinity//from   w  ww .j a  va  2  s  . co  m
 */
private int addPagesToSection(Document document, Element sectionElement, File brailleFile, int maxRows,
        int maxCols, int maxPages) throws IOException, Exception {

    int pageCount = 0;

    FileInputStream fileInputStream = new FileInputStream(brailleFile);
    InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8");
    BufferedReader bufferedReader = new BufferedReader(inputStreamReader);

    Element pageElement;
    Element rowElement;
    Node textNode;
    String line;

    boolean nextPage = bufferedReader.ready() && (maxPages > pageCount || maxPages == -1);

    try {
        while (nextPage) {
            pageElement = document.createElementNS(pefNS, "page");
            for (int i = 0; i < maxRows; i++) {
                line = bufferedReader.readLine();
                if (line == null) {
                    throw new Exception("number of rows < " + maxRows);
                }
                line = line.replaceAll("\u2800", "\u0020").replaceAll("\u00A0", "\u0020")
                        .replaceAll("\uE00F", "\u002D").replaceAll("\uE000", "\u0020");
                if (line.length() > maxCols) {
                    throw new Exception("line length > " + maxCols);
                }
                rowElement = document.createElementNS(pefNS, "row");
                textNode = document.createTextNode(liblouisTable.toBraille(line));
                rowElement.appendChild(textNode);
                pageElement.appendChild(rowElement);
                if (IS_WINDOWS) {
                    bufferedReader.readLine();
                }
            }

            sectionElement.appendChild(pageElement);
            pageCount++;
            if (bufferedReader.read() != '\f') {
                throw new Exception("unexpected character, should be form feed");
            }
            nextPage = nextPage = bufferedReader.ready() && (maxPages > pageCount || maxPages == -1);
        }

    } finally {
        if (bufferedReader != null) {
            bufferedReader.close();
            inputStreamReader.close();
            fileInputStream.close();
        }
    }

    return pageCount;
}

From source file:com.wso2telco.dep.reportingservice.northbound.NbHostObjectUtils.java

/**
 * Gets the custom report.//from  w ww .  ja v  a2 s  .  c  o  m
 *
 * @param fromDate the from date
 * @param toDate the to date
 * @param subscriberName the subscriber name
 * @param operator the operator
 * @param api the api
 * @return the custom report
 */
public static String getCustomReport(String fromDate, String toDate, String subscriberName, String operator,
        String api) {
    String fileContent = "";
    BufferedReader bufferedReader = null;
    try {
        File file = getCustomCSVFile(fromDate, toDate, subscriberName, operator, api);
        bufferedReader = new BufferedReader(new FileReader(file));

        StringBuilder fileAppender = new StringBuilder();

        int c = -1;

        while ((c = bufferedReader.read()) != -1) {
            char ch = (char) c;
            fileAppender.append(ch);
        }
        fileContent = fileAppender.toString();

    } catch (IOException e) {
        log.error("report file reading error : " + e.getMessage());
    } finally {
        try {
            bufferedReader.close();
        } catch (IOException e) {
            log.error("Buuffered Reader closing error : " + e.getMessage());
        }
    }
    return fileContent;
}

From source file:org.opendaylight.lispflowmapping.integrationtest.MappingServiceIntegrationTest.java

License:asdf

private String callURL(String method, String content, String accept, String body, URL url)
        throws IOException, JSONException {
    String authStringEnc = createAuthenticationString();
    connection = (HttpURLConnection) url.openConnection();
    connection.setRequestMethod(method);
    connection.setRequestProperty("Authorization", "Basic " + authStringEnc);
    if (content != null) {
        connection.setRequestProperty("Content-Type", content);
    }// w  w  w .  j a v  a 2 s  . c o  m
    if (accept != null) {
        connection.setRequestProperty("Accept", accept);
    }
    if (body != null) {
        // now add the request body
        connection.setDoOutput(true);
        OutputStreamWriter wr = new OutputStreamWriter(connection.getOutputStream());
        wr.write(body);
        wr.flush();
    }
    connection.connect();

    // getting the result, first check response code
    Integer httpResponseCode = connection.getResponseCode();

    if (httpResponseCode > 299) {
        LOG.trace("HTTP Address: " + url);
        LOG.trace("HTTP Response Code: " + httpResponseCode);
        fail();
    }

    InputStream is = connection.getInputStream();
    BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
    StringBuilder sb = new StringBuilder();
    int cp;
    while ((cp = rd.read()) != -1) {
        sb.append((char) cp);
    }
    is.close();
    connection.disconnect();
    return (sb.toString());
}

From source file:org.jab.docsearch.Index.java

/**
 * Obtains Meta Data for a web page//from   w w  w . ja  va  2  s .  co  m
 *
 * @param filename  filename of webpage
 * @return author, title, and summary of a web page speficied in filename
 */
public WebPageMetaData getWebPageMetaData(String filename) {
    WebPageMetaData tempWpmd = new WebPageMetaData();
    tempWpmd.setFilename(filename);

    BufferedReader reader = null;
    PrintWriter writer = null;
    try {
        boolean inTag = false;
        boolean foundSummary = false;
        boolean inBody = false;
        boolean inScript = false;
        boolean inTitle = false;

        StringBuffer tagBuf = new StringBuffer();
        StringBuffer titleBuf = new StringBuffer();
        StringBuffer summaryBuf = new StringBuffer();

        // open reader and writer
        File origFile = new File(filename);
        reader = new BufferedReader(new InputStreamReader(new FileInputStream(origFile)));
        writer = new PrintWriter(new FileWriter(ds.htmlTextFile));

        StringBuffer nonTagTextf = new StringBuffer();
        int curBodyNonTagTextNum = 0;
        int sumMaxSize = 220;
        int ch;

        // step during html source
        while ((ch = reader.read()) > -1) {
            char curChar = (char) ch;

            if (curChar == '>') {
                inTag = false;
                //
                tagBuf.append(curChar);
                String realTag = tagBuf.toString();
                String lowerTag = realTag.toLowerCase();
                if (lowerTag.startsWith(META_TAG)) {
                    String tempMetaName = Utils.getTagString("name=", lowerTag);
                    if (tempMetaName.startsWith("description")) {
                        String tempMetaContent = Utils.getTagString("content=", realTag);
                        if (!tempMetaContent.trim().equals("")) {
                            tempWpmd.setDescription(tempMetaContent);
                            foundSummary = true;
                        }
                    } else if (tempMetaName.startsWith("summary")) {
                        String tempMetaContent = Utils.getTagString("content=", realTag);
                        if (!tempMetaContent.trim().equals("")) {
                            tempWpmd.setDescription(tempMetaContent);
                            foundSummary = true;
                        }
                    } else if (tempMetaName.startsWith("author") || tempMetaName.indexOf("webmaster") != -1) {
                        String tempMetaContent = Utils.getTagString("content=", realTag);
                        tempWpmd.setAuthor(tempMetaContent);
                    }
                } else if (lowerTag.startsWith(SCRIPT_TAG)) {
                    if (!lowerTag.endsWith("/>")) {
                        inScript = true;
                    }
                } else if (lowerTag.startsWith(SCRIPT_TAG_END)) {
                    inScript = false;
                } else if (lowerTag.startsWith(BODY_TAG)) {
                    inBody = true;
                } else if (lowerTag.startsWith(BODY_TAG_END)) {
                    inBody = false;
                } else if (lowerTag.startsWith(TITLE_TAG)) {
                    inTitle = true;
                } else if (lowerTag.startsWith(TITLE_TAG_END)) {
                    inTitle = false;
                    tempWpmd.setTitle(titleBuf.toString());
                }
                // reset our buffers
                tagBuf = new StringBuffer();
                nonTagTextf = new StringBuffer();
            } else if (curChar == '<') {
                inTag = true;
                tagBuf = new StringBuffer();
                String t = nonTagTextf.toString().trim();
                int tSize = t.length();
                if (tSize > 0) {
                    if (!inScript && inBody) {
                        writer.println(t);
                    }
                }
                nonTagTextf = new StringBuffer();
                //
                if (!foundSummary) {
                    //
                    if (inBody) {
                        curBodyNonTagTextNum += tSize;
                        summaryBuf.append(' ');
                        summaryBuf.append(t);
                        summaryBuf.append(' ');
                        if (curBodyNonTagTextNum >= sumMaxSize) {
                            tempWpmd.setDescription(Utils.concatStrToEnd(summaryBuf.toString(), sumMaxSize));
                            foundSummary = true;
                        }
                    }
                }
                //
            } // end for the beginning of a tag
            if (inTitle && curChar != '>' && !inTag) {
                titleBuf.append(curChar);
            } else if (!inTag && curChar != '>') {
                nonTagTextf.append(curChar);
            } else if (inTag) {
                tagBuf.append(curChar);
            }
        } // end for while reading

        if (!foundSummary && curBodyNonTagTextNum > 0) {
            tempWpmd.setDescription(summaryBuf.toString());
        }
    } catch (IOException ioe) {
        logger.error("getWebPageMetaData() failed", ioe);
        ds.setStatus(I18n.getString("error") + " : " + ioe.toString());
    } finally {
        IOUtils.closeQuietly(reader);
        IOUtils.closeQuietly(writer);
    }

    return tempWpmd;
}