当前位置: 首页>>代码示例>>Java>>正文


Java ByteArrayBuffer类代码示例

本文整理汇总了Java中org.apache.http.util.ByteArrayBuffer的典型用法代码示例。如果您正苦于以下问题:Java ByteArrayBuffer类的具体用法?Java ByteArrayBuffer怎么用?Java ByteArrayBuffer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ByteArrayBuffer类属于org.apache.http.util包,在下文中一共展示了ByteArrayBuffer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import org.apache.http.util.ByteArrayBuffer; //导入依赖的package包/类
/**
 * Initializes this session input buffer.
 *
 * @param instream the source input stream.
 * @param buffersize the size of the internal buffer.
 * @param params HTTP parameters.
 */
protected void init(final InputStream instream, int buffersize, final HttpParams params) {
    if (instream == null) {
        throw new IllegalArgumentException("Input stream may not be null");
    }
    if (buffersize <= 0) {
        throw new IllegalArgumentException("Buffer size may not be negative or zero");
    }
    if (params == null) {
        throw new IllegalArgumentException("HTTP parameters may not be null");
    }
    this.instream = instream;
    this.buffer = new byte[buffersize];
    this.bufferpos = 0;
    this.bufferlen = 0;
    this.linebuffer = new ByteArrayBuffer(buffersize);
    this.charset = Charset.forName(HttpProtocolParams.getHttpElementCharset(params));
    this.ascii = this.charset.equals(ASCII);
    this.decoder = null;
    this.maxLineLen = params.getIntParameter(CoreConnectionPNames.MAX_LINE_LENGTH, -1);
    this.minChunkLimit = params.getIntParameter(CoreConnectionPNames.MIN_CHUNK_LIMIT, 512);
    this.metrics = createTransportMetrics();
    this.onMalformedInputAction = HttpProtocolParams.getMalformedInputAction(params);
    this.onUnMappableInputAction = HttpProtocolParams.getUnmappableInputAction(params);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:32,代码来源:AbstractSessionInputBuffer.java

示例2: init

import org.apache.http.util.ByteArrayBuffer; //导入依赖的package包/类
/**
 * Initializes this session output buffer.
 *
 * @param outstream the destination output stream.
 * @param buffersize the size of the internal buffer.
 * @param params HTTP parameters.
 */
protected void init(final OutputStream outstream, int buffersize, final HttpParams params) {
    if (outstream == null) {
        throw new IllegalArgumentException("Input stream may not be null");
    }
    if (buffersize <= 0) {
        throw new IllegalArgumentException("Buffer size may not be negative or zero");
    }
    if (params == null) {
        throw new IllegalArgumentException("HTTP parameters may not be null");
    }
    this.outstream = outstream;
    this.buffer = new ByteArrayBuffer(buffersize);
    this.charset = Charset.forName(HttpProtocolParams.getHttpElementCharset(params));
    this.ascii = this.charset.equals(ASCII);
    this.encoder = null;
    this.minChunkLimit = params.getIntParameter(CoreConnectionPNames.MIN_CHUNK_LIMIT, 512);
    this.metrics = createTransportMetrics();
    this.onMalformedInputAction = HttpProtocolParams.getMalformedInputAction(params);
    this.onUnMappableInputAction = HttpProtocolParams.getUnmappableInputAction(params);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:28,代码来源:AbstractSessionOutputBuffer.java

示例3: SessionInputBufferImpl

import org.apache.http.util.ByteArrayBuffer; //导入依赖的package包/类
/**
 * Creates new instance of SessionInputBufferImpl.
 *
 * @param metrics HTTP transport metrics.
 * @param buffersize buffer size. Must be a positive number.
 * @param minChunkLimit size limit below which data chunks should be buffered in memory
 *   in order to minimize native method invocations on the underlying network socket.
 *   The optimal value of this parameter can be platform specific and defines a trade-off
 *   between performance of memory copy operations and that of native method invocation.
 *   If negative default chunk limited will be used.
 * @param constraints Message constraints. If <code>null</code>
 *   {@link MessageConstraints#DEFAULT} will be used.
 * @param chardecoder chardecoder to be used for decoding HTTP protocol elements.
 *   If <code>null</code> simple type cast will be used for byte to char conversion.
 */
public SessionInputBufferImpl(
        final HttpTransportMetricsImpl metrics,
        final int buffersize,
        final int minChunkLimit,
        final MessageConstraints constraints,
        final CharsetDecoder chardecoder) {
    Args.notNull(metrics, "HTTP transport metrcis");
    Args.positive(buffersize, "Buffer size");
    this.metrics = metrics;
    this.buffer = new byte[buffersize];
    this.bufferpos = 0;
    this.bufferlen = 0;
    this.minChunkLimit = minChunkLimit >= 0 ? minChunkLimit : 512;
    this.constraints = constraints != null ? constraints : MessageConstraints.DEFAULT;
    this.linebuffer = new ByteArrayBuffer(buffersize);
    this.decoder = chardecoder;
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:33,代码来源:SessionInputBufferImpl.java

示例4: extractResponseBytes

import org.apache.http.util.ByteArrayBuffer; //导入依赖的package包/类
private byte[] extractResponseBytes(InputStream is) throws IOException {
    BufferedInputStream bis = null;
    BufferedReader br = null;
    try {
        ByteArrayBuffer baf = new ByteArrayBuffer(1024);
        bis = new BufferedInputStream(is);
        int b = 0;
        while ((b = bis.read()) != -1)
            baf.append((byte) b);
        byte[] bytes = baf.toByteArray();
        return bytes;
    }
    finally {
        if (bis != null)
            bis.close();
        if (br != null)
            br.close();
    }
}
 
开发者ID:CenturyLinkCloud,项目名称:mdw,代码行数:20,代码来源:HttpAltConnection.java

示例5: doWriteTo

import org.apache.http.util.ByteArrayBuffer; //导入依赖的package包/类
void doWriteTo(
    final OutputStream out,
    final boolean writeContent) throws IOException {

    final ByteArrayBuffer boundaryEncoded = encode(this.charset, this.boundary);
    for (final FormBodyPart part: getBodyParts()) {
        writeBytes(TWO_DASHES, out);
        writeBytes(boundaryEncoded, out);
        writeBytes(CR_LF, out);

        formatMultipartHeader(part, out);

        writeBytes(CR_LF, out);

        if (writeContent) {
            part.getBody().writeTo(out);
        }
        writeBytes(CR_LF, out);
    }
    writeBytes(TWO_DASHES, out);
    writeBytes(boundaryEncoded, out);
    writeBytes(TWO_DASHES, out);
    writeBytes(CR_LF, out);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:25,代码来源:AbstractMultipartForm.java

示例6: getResponse

import org.apache.http.util.ByteArrayBuffer; //导入依赖的package包/类
public static String getResponse(String reqUrl) throws Exception {
	final URL url = new URL(reqUrl);
	final URLConnection ucon = url.openConnection();

	/* Define InputStreams to read
	 * from the URLConnection. */
	final InputStream is = ucon.getInputStream();
	final BufferedInputStream bis = new BufferedInputStream(is);

	/* Read bytes to the Buffer until
	 * there is nothing more to read(-1). */
	final ByteArrayBuffer baf = new ByteArrayBuffer(50);
	int current = 0;
	while((current = bis.read()) != -1){
		baf.append((byte)current);
	}

	return new String(baf.toByteArray());
}
 
开发者ID:sunnygoyal,项目名称:neon-clock-legacy,代码行数:20,代码来源:WeatherService.java

示例7: getLogoImage

import org.apache.http.util.ByteArrayBuffer; //导入依赖的package包/类
private byte[] getLogoImage(String url) {
    try {
        URL imageUrl = new URL(url);
        URLConnection ucon = imageUrl.openConnection();
        InputStream is = ucon.getInputStream();
        BufferedInputStream bis = new BufferedInputStream(is);
        ByteArrayBuffer baf = new ByteArrayBuffer(500);
        int current = 0;

        while ((current = bis.read()) != -1) {
            baf.append((byte) current);

        }
        return baf.toByteArray();


    } catch (Exception e) {
        Log.d("ImageManager", "Error: " + e.toString());
        return null;
    }

}
 
开发者ID:tranquang9a1,项目名称:ECRM,代码行数:23,代码来源:LoginActivity.java

示例8: DownloadFromUrl

import org.apache.http.util.ByteArrayBuffer; //导入依赖的package包/类
public static String DownloadFromUrl(String u) {
    try {
        URL url = new URL(u);
        URLConnection ucon = url.openConnection();
        InputStream is = ucon.getInputStream();
        BufferedInputStream bis = new BufferedInputStream(is);
        ByteArrayBuffer baf = new ByteArrayBuffer(50);
        int current = 0;
        while ((current = bis.read()) != -1) {
            baf.append((byte) current);
        }

        return  new String(baf.toByteArray());

    } catch (Exception e) {
        Log.e(TAG, "Error: " + e);
    }
    return  null;
}
 
开发者ID:balscit,项目名称:Padio,代码行数:20,代码来源:Settings.java

示例9: hexToBytes

import org.apache.http.util.ByteArrayBuffer; //导入依赖的package包/类
public static byte[] hexToBytes(String hex) {
    ByteArrayBuffer bytes = new ByteArrayBuffer(hex.length() / 2);
    for (int i = 0; i < hex.length(); i++) {
        if (hex.charAt(i) == ' ') {
            continue;
        }

        String hexByte;
        if (i + 1 < hex.length()) {
            hexByte = hex.substring(i, i + 2).trim();
            i++;
        } else {
            hexByte = hex.substring(i, i + 1);
        }

        bytes.append(Integer.parseInt(hexByte, 16));
    }
    return bytes.buffer();
}
 
开发者ID:Ossit,项目名称:SenseBack,代码行数:20,代码来源:HexAsciiHelper.java

示例10: inputStreamToString

import org.apache.http.util.ByteArrayBuffer; //导入依赖的package包/类
/**
 * 将inputStream 以系统默认编码转换为字符串
 * 
 * @param 字节流
 * 
 */
public String inputStreamToString(InputStream is) throws IOException {
	byte arr[] = new byte[1024];
	ByteArrayBuffer byteArrayBuffer = new ByteArrayBuffer(1024);
	int len = 0;
	try {
		while ((len = is.read(arr)) != -1) {
			byteArrayBuffer.append(arr, 0, len);
		}
	} finally {
		try {
			is.close();
		} catch (IOException e) {
			// do nothing
		}
	}
	return new String(byteArrayBuffer.toByteArray());
}
 
开发者ID:tincent,项目名称:libtincent,代码行数:24,代码来源:TXStringUtils.java

示例11: getHtmlString

import org.apache.http.util.ByteArrayBuffer; //导入依赖的package包/类
public static String getHtmlString(String urlString) {  
    try {
        URL url = new URL(urlString);  
        URLConnection ucon = url.openConnection();  
        InputStream instr = ucon.getInputStream();  
        BufferedInputStream bis = new BufferedInputStream(instr); 
        ByteArrayBuffer baf = new ByteArrayBuffer(500);  
        int current = 0;  
        while ((current = bis.read()) != -1) {  
            baf.append((byte) current);  
        }  
        return EncodingUtils.getString(baf.toByteArray(), "utf-8");  
    } catch (Exception e) {
    	
    	Log.d("win","lllll"+e.toString());
        return "";  
    }  
}
 
开发者ID:dotcool,项目名称:mvideo,代码行数:19,代码来源:HttpUtil.java

示例12: HttpGet

import org.apache.http.util.ByteArrayBuffer; //导入依赖的package包/类
public static ByteArrayBuffer ʻ(String paramString)
{
  HttpGet localHttpGet = new HttpGet(paramString);
  DefaultHttpClient localDefaultHttpClient = ˊ();
  BufferedHttpEntity localBufferedHttpEntity = new BufferedHttpEntity(localDefaultHttpClient.execute(localHttpGet).getEntity());
  BufferedInputStream localBufferedInputStream = new BufferedInputStream(localBufferedHttpEntity.getContent());
  ByteArrayBuffer localByteArrayBuffer = new ByteArrayBuffer(50);
  while (true)
  {
    int i = localBufferedInputStream.read();
    if (i == -1)
      break;
    localByteArrayBuffer.append((byte)i);
  }
  localBufferedInputStream.close();
  localBufferedHttpEntity.consumeContent();
  localDefaultHttpClient.getConnectionManager().shutdown();
  return localByteArrayBuffer;
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:20,代码来源:„Ä≥.java

示例13: downloadIconFromUrl

import org.apache.http.util.ByteArrayBuffer; //导入依赖的package包/类
@ィ(ˊ="DOWNLOAD_ICON_ASSET")
public final void downloadIconFromUrl(String paramString, File paramFile)
{
  int i = paramString.hashCode();
  if (!this.ˎ.contains(Integer.valueOf(i)))
  {
    this.ˎ.add(Integer.valueOf(i));
    try
    {
      ByteArrayBuffer localByteArrayBuffer = 〳.ʻ(paramString);
      paramFile.getParentFile().mkdirs();
      FileOutputStream localFileOutputStream = new FileOutputStream(paramFile);
      localFileOutputStream.write(localByteArrayBuffer.toByteArray());
      localFileOutputStream.close();
    }
    catch (IOException localIOException)
    {
    }
    this.ˎ.remove(Integer.valueOf(i));
  }
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:22,代码来源:‡πÅ.java

示例14: File

import org.apache.http.util.ByteArrayBuffer; //导入依赖的package包/类
public static void ˊ(Context paramContext, ByteArrayBuffer paramByteArrayBuffer, String paramString1, String paramString2)
{
  File localFile = new File(paramContext.getCacheDir(), String.valueOf((paramString1 + paramString2).hashCode()));
  try
  {
    FileOutputStream localFileOutputStream = new FileOutputStream(localFile);
    localFileOutputStream.write(paramByteArrayBuffer.toByteArray());
    localFileOutputStream.close();
    return;
  }
  catch (FileNotFoundException localFileNotFoundException)
  {
    localFileNotFoundException.printStackTrace();
    return;
  }
  catch (IOException localIOException)
  {
    localIOException.printStackTrace();
  }
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:21,代码来源:œü.java

示例15: catch

import org.apache.http.util.ByteArrayBuffer; //导入依赖的package包/类
private static ByteArrayBuffer ˊ(String[] paramArrayOfString)
{
  try
  {
    ByteArrayBuffer localByteArrayBuffer = 〳.ʻ(paramArrayOfString[0]);
    return localByteArrayBuffer;
  }
  catch (IOException localIOException)
  {
    localIOException.printStackTrace();
    return null;
  }
  catch (Exception localException)
  {
    localException.printStackTrace();
  }
  return null;
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:19,代码来源:·é´.java


注:本文中的org.apache.http.util.ByteArrayBuffer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。