posts - 262,  comments - 221,  trackbacks - 0
     摘要: ThreadLocal作用解析及代码实例  阅读全文
posted @ 2008-09-05 17:10 Paul Lin 阅读(4756) | 评论 (1)编辑 收藏
     摘要: Java反射之Array  阅读全文
posted @ 2008-09-04 15:13 Paul Lin 阅读(1144) | 评论 (0)编辑 收藏
     摘要: Java反射之Filed  阅读全文
posted @ 2008-09-04 15:02 Paul Lin 阅读(408) | 评论 (0)编辑 收藏
     摘要: Java反射之Method  阅读全文
posted @ 2008-09-03 16:05 Paul Lin 阅读(1831) | 评论 (0)编辑 收藏
     摘要: Java反射之Class  阅读全文
posted @ 2008-09-03 14:36 Paul Lin 阅读(352) | 评论 (0)编辑 收藏
     摘要: 【一】进程、线程、并发执行
【二】JVM与多线程
【三】Java语言对多线程的支持
【四】线程的状态切换
【五】Java中线程的调度API
【六】参考文章  阅读全文
posted @ 2008-09-02 10:50 Paul Lin 阅读(3910) | 评论 (3)编辑 收藏
     摘要: CSS常用属性设置  阅读全文
posted @ 2008-08-17 10:56 Paul Lin 阅读(1126) | 评论 (0)编辑 收藏
     摘要: 多线程池化Socket服务器  阅读全文
posted @ 2008-08-16 23:08 Paul Lin 阅读(7267) | 评论 (0)编辑 收藏

该方法中使用一个无限循环,从字节流中读取字节,存放到byte数组中,每次读取1024个字节(一般都是这个设置),由于每次读取的字节数量不一定够1024个(比如最后一次的读取就可能不够),所以我们要记录每次实际读到的字节数,然后将实际读取到的字节按指定的编码方式转换成字符串。

private String inputStreamToString(InputStream is, String encoding) {
    try {
        
byte[] b = new byte[1024];
         String res 
= "";
         
if (is == null) {
                
return "";
         }
         
         
int bytesRead = 0;
        
while (true) {
             bytesRead 
= is.read(b, 01024); // return final read bytes counts
             
if (bytesRead == -1) {// end of InputStream
                    return res;
             }
             res +=
 new String(b, 0, bytesRead, encoding); // convert to string using bytes
          }
      } 
catch (Exception e) {
            e.printStackTrace();
            System.out.print(
"Exception: " + e);
            
return "";
      }
}
posted @ 2008-08-06 09:59 Paul Lin 阅读(17325) | 评论 (2)编辑 收藏
     摘要: CSS基础知识总结之盒状模型和Z-index  阅读全文
posted @ 2008-08-01 21:57 Paul Lin 阅读(326) | 评论 (0)编辑 收藏
仅列出标题
共26页: First 上一页 13 14 15 16 17 18 19 20 21 下一页 Last 
<2025年6月>
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345

常用链接

留言簿(21)

随笔分类

随笔档案

BlogJava热点博客

好友博客

搜索

  •  

最新评论

阅读排行榜

评论排行榜