當前位置: 首頁>>代碼示例>>Java>>正文


Java CharArrayBuffer.toString方法代碼示例

本文整理匯總了Java中org.apache.http.util.CharArrayBuffer.toString方法的典型用法代碼示例。如果您正苦於以下問題:Java CharArrayBuffer.toString方法的具體用法?Java CharArrayBuffer.toString怎麽用?Java CharArrayBuffer.toString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.http.util.CharArrayBuffer的用法示例。


在下文中一共展示了CharArrayBuffer.toString方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getCondensedHeader

import org.apache.http.util.CharArrayBuffer; //導入方法依賴的package包/類
/**
 * Gets a header representing all of the header values with the given name.
 * If more that one header with the given name exists the values will be
 * combined with a "," as per RFC 2616.
 *
 * <p>Header name comparison is case insensitive.
 *
 * @param name the name of the header(s) to get
 * @return a header with a condensed value or <code>null</code> if no
 * headers by the given name are present
 */
public Header getCondensedHeader(String name) {
    Header[] headers = getHeaders(name);

    if (headers.length == 0) {
        return null;
    } else if (headers.length == 1) {
        return headers[0];
    } else {
        CharArrayBuffer valueBuffer = new CharArrayBuffer(128);
        valueBuffer.append(headers[0].getValue());
        for (int i = 1; i < headers.length; i++) {
            valueBuffer.append(", ");
            valueBuffer.append(headers[i].getValue());
        }

        return new BasicHeader(name.toLowerCase(Locale.ENGLISH), valueBuffer.toString());
    }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:30,代碼來源:HeaderGroup.java

示例2: BufferedHeader

import org.apache.http.util.CharArrayBuffer; //導入方法依賴的package包/類
/**
 * Creates a new header from a buffer.
 * The name of the header will be parsed immediately,
 * the value only if it is accessed.
 *
 * @param buffer    the buffer containing the header to represent
 *
 * @throws ParseException   in case of a parse error
 */
public BufferedHeader(final CharArrayBuffer buffer)
    throws ParseException {

    super();
    if (buffer == null) {
        throw new IllegalArgumentException
            ("Char array buffer may not be null");
    }
    int colon = buffer.indexOf(':');
    if (colon == -1) {
        throw new ParseException
            ("Invalid header: " + buffer.toString());
    }
    String s = buffer.substringTrimmed(0, colon);
    if (s.length() == 0) {
        throw new ParseException
            ("Invalid header: " + buffer.toString());
    }
    this.buffer = buffer;
    this.name = s;
    this.valuePos = colon + 1;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:32,代碼來源:BufferedHeader.java

示例3: readLine

import org.apache.http.util.CharArrayBuffer; //導入方法依賴的package包/類
public String readLine() throws IOException {
    CharArrayBuffer charbuffer = new CharArrayBuffer(64);
    int l = readLine(charbuffer);
    if (l != -1) {
        return charbuffer.toString();
    } else {
        return null;
    }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:10,代碼來源:AbstractSessionInputBuffer.java

示例4: gzipToString

import org.apache.http.util.CharArrayBuffer; //導入方法依賴的package包/類
public static String gzipToString(final HttpEntity entity, final String defaultCharset) throws IOException, ParseException {
	if (entity == null) {
		throw new IllegalArgumentException("HTTP entity may not be null");
	}
	InputStream instream = entity.getContent();
	if (instream == null) {
		return "";
	}
	// gzip logic start
	if (entity.getContentEncoding().getValue().contains("gzip")) {
		instream = new GZIPInputStream(instream);
	}
	// gzip logic end
	if (entity.getContentLength() > Integer.MAX_VALUE) {
		throw new IllegalArgumentException("HTTP entity too large to be buffered in memory");
	}
	int i = (int)entity.getContentLength();
	if (i < 0) {
		i = 4096;
	}
	String charset = EntityUtils.getContentCharSet(entity);
	if (charset == null) {
		charset = defaultCharset;
	}
	if (charset == null) {
		charset = HTTP.DEFAULT_CONTENT_CHARSET;
	}
	Reader reader = new InputStreamReader(instream, charset);
	CharArrayBuffer buffer = new CharArrayBuffer(i);
	try {
		char[] tmp = new char[1024];
		int l;
		while((l = reader.read(tmp)) != -1) {
			buffer.append(tmp, 0, l);
		}
	} finally {
		reader.close();
	}
	return buffer.toString();
}
 
開發者ID:liningwang,項目名稱:camera,代碼行數:41,代碼來源:AppUtil.java

示例5: toString

import org.apache.http.util.CharArrayBuffer; //導入方法依賴的package包/類
/**
 * Generates textual representation of this content type which can be used as the value
 * of a <code>Content-Type</code> header.
 */
@Override
public String toString() {
    final CharArrayBuffer buf = new CharArrayBuffer(64);
    buf.append(this.mimeType);
    if (this.params != null) {
        buf.append("; ");
        BasicHeaderValueFormatterHC4.INSTANCE.formatParameters(buf, this.params, false);
    } else if (this.charset != null) {
        buf.append("; charset=");
        buf.append(this.charset.name());
    }
    return buf.toString();
}
 
開發者ID:xxonehjh,項目名稱:remote-files-sync,代碼行數:18,代碼來源:ContentType.java

示例6: readLine

import org.apache.http.util.CharArrayBuffer; //導入方法依賴的package包/類
public String readLine() throws IOException {
    final CharArrayBuffer charbuffer = new CharArrayBuffer(64);
    final int l = readLine(charbuffer);
    if (l != -1) {
        return charbuffer.toString();
    } else {
        return null;
    }
}
 
開發者ID:xxonehjh,項目名稱:remote-files-sync,代碼行數:10,代碼來源:SessionInputBufferImpl.java

示例7: doSendResponse

import org.apache.http.util.CharArrayBuffer; //導入方法依賴的package包/類
@Override
public void doSendResponse(RestResponse response) {
    status = response.status().getStatus();

    byte[] bytes = response.content().toBytes();
    long length = bytes.length;
    Args.check(length <= Integer.MAX_VALUE, "HTTP entity too large to be buffered in memory");
    if(length < 0) {
        length = 4096;
    }

    InputStream instream =  new ByteArrayInputStream(bytes);
    InputStreamReader reader = new InputStreamReader(instream, Consts.UTF_8);
    CharArrayBuffer buffer = new CharArrayBuffer((int)length);
    char[] tmp = new char[1024];

    int l;
    try {
        while ((l = reader.read(tmp)) != -1) {
            buffer.append(tmp, 0, l);
        }
        content = buffer.toString();
    } catch (IOException e) {
        status = RestStatus.INTERNAL_SERVER_ERROR.getStatus();
        content = "IOException: " + e.getMessage();
    } finally {
        try {
            reader.close();
            instream.close();
        } catch (IOException e1) {
            content = "IOException: " + e1.getMessage();
        } finally {
            count.countDown();
        }
    }
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:37,代碼來源:LocalRestChannel.java


注:本文中的org.apache.http.util.CharArrayBuffer.toString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。