Quantcast
Channel: BlogJava--随笔分类-java
Browsing all 31 articles
Browse latest View live

Image may be NSFW.
Clik here to view.

字符集和编码方式(转)

搞清常用编码特性是解决字符集编码问题的基础。字符集编码的识别与转换、分析各种乱码产生的原因、编程操作各种编码字符串(例如字符数计算、截断处理)等都需要弄清楚编码的特性。 了解一种字符集编码主要是要了解该编码的编码范围,编码对应的字符集(都包含哪些字符),和其他字符集编码之间的关系等。 --------1. ASCII--------...

View Article


Image may be NSFW.
Clik here to view.

HttpURLConnection 的使用

System.setProperty("sun.net.client.defaultConnectTimeout", "3000");        System.setProperty("sun.net.client.defaultReadTime ", "3000");                 URL url1=null;        try {            url1 =...

View Article


Image may be NSFW.
Clik here to view.

数学公式解析和计算

JEPhttp://www.singularsys.com/jep/https://sourceforge.net/projects/jep/http://rabbit8.bokee.com/3936531.htmlhttp://suneca.com/article.asp?id=28http://www.javaeye.com/topic/58422里办法多关于jexl1,jexl1.1计算分母为...

View Article

Image may be NSFW.
Clik here to view.

操作数组

1,List转数组    List list = new ArrayList();        list.add("1");        list.add("2");        int size = list.size();        String[] arr = (String[]) list.toArray(new String[size]);     必须带参数new...

View Article

Image may be NSFW.
Clik here to view.

java.io.CharConversionException: Not an ISO 8859-1 character: xx

调用Action获取字符串,其中包含中文,使用如下代码输出: ServletOutputStream out = response.getOutputStream(); request.setAttribute("xmlTree", tree); out.print(tree);使用的编码是GBK,在JDK1.5运行抛出异常:java.io.CharConversionException: Not...

View Article


Image may be NSFW.
Clik here to view.

HttpURLConnection设置网络超时

Java中可以使用HttpURLConnection来请求WEB资源。HttpURLConnection对象不能直接构造,需要通过 URL.openConnection()来获得HttpURLConnection对象,示例代码如下:String urlStr= www.ttt.org;URL url = new URL(urlStr);HttpURLConnection conn =...

View Article

Image may be NSFW.
Clik here to view.

HttpURLConnection timeout solution

From: Niels Campbell (niels_campbell_at_lycos.co.uk)Date: 01/23/04Date: 23 Jan 2004 09:14:16 -0800After spending nearly 3 days on this problem to come up with a solution I think it is only right to...

View Article

Image may be NSFW.
Clik here to view.

Adding Socket Timeout to java.net.URLConnection (JDK 1.2)

Adding Socket Timeout to java.net.URLConnection (JDK 1.2) found a bug , see "connected = true;" in public void connect() throws IOException { Note: 05/11/01 Sam Found a patch for borland As I got the...

View Article


Image may be NSFW.
Clik here to view.

正则表达式笔记

String regex = "<a.*?/a>";//取链接        Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);        Matcher mt = pattern.matcher(str);        while (mt.find()) {        String...

View Article


Image may be NSFW.
Clik here to view.

JVM笔记

1,http://www.javaeye.com/topic/143987在新版本的java里面,同步比gc慢 所以以前很多framework里面都有pool的设定,现在都取消了 现在只有一些数据库连接等IO资源做pool以外,基本的数据class已经都不作pool了pool 一般用在创建很大消费的对象时才用的。 比如 connection, tapestry的page。 像new...

View Article

Image may be NSFW.
Clik here to view.

log笔记

1,为什么要写 if (log.isDebugEnabled())在使用log4j,common-log这样的log框架时,发现很多代码中这样写 if   (log.isDebugEnabled())   {           log.debug( "xxxx "); }...

View Article

Image may be NSFW.
Clik here to view.

分页

http://www.javaeye.com/topic/470144http://www.javaeye.com/topic/121756http://www.javaeye.com/topic/57909http://www.javaeye.com/topic/400225http://www.blogjava.net/weijy/archive/2008/09/27/231449.htmlht...

View Article

Image may be NSFW.
Clik here to view.

java处理浮点数

    public void testBigDecimalEquals() {        assertEquals(new BigDecimal("3.50"),new BigDecimal("3.5"));//不相等    } System.out.println(0.030*100);//输出3.0 System.out.println(0.031*100);//输出3.1...

View Article


Image may be NSFW.
Clik here to view.

线程安全类

当一个类已经很好的同步以保护它的数据时,这个类就称为“线程安全的”。 即使是线程安全类,也应该特别小心,因为操作的线程是间仍然不一定安全。import java.util.Collections;import java.util.LinkedList;import java.util.List;public class TestThread {    public static void...

View Article

Image may be NSFW.
Clik here to view.

java的static

Static 的意义与实作方式   Class(static) field :共用一块记忆体 class(static) method :共用一块记忆体 instance( 非 static) field :随着每个 instance 各有一块记忆体 instance ( 非 static) method :共用一块记忆体     instance method 为什么不是随着每个...

View Article


Image may be NSFW.
Clik here to view.

值和引用

JDK1.6          Integer v1 = 100;        Integer v2 = 100;        System.out.println(v1 == v2); // 输出:true                Integer w1 = 200;        Integer w2 = 200;        System.out.println(w1 == w2);...

View Article

Image may be NSFW.
Clik here to view.

深入java虚拟机笔记

1,java体系结构包括四个独立但相关的技术:java语言、class文件格式、java的api、java虚拟机2,java虚拟机是一台抽象的计算机,主要任务是装载class文件并且执行其中的字节码。不同的java虚拟机,其执行引擎的实现可能不一样。分为软件实现和硬件实现(内嵌在芯片),软件实现有以下几种:(1)每次都会解释字节码(2)即时编译,即编译成本低机器代码,缓存起来可以重用(3)自适应优化...

View Article


Image may be NSFW.
Clik here to view.

java类的加载

打印Thread.currentThread().getContextClassLoader(),显示如下:sun.misc.Launcher$AppClassLoader@19821f这个加载器是系统类加载器。ClassLoader.getSystemResourceAsStream("com/config.xml")使用的就是系统类加载器定位资源的。...

View Article

Image may be NSFW.
Clik here to view.

关于OSGI

参考:1,OSGi,Java模块化框架的另类进化 http://developer.51cto.com/art/201003/190584.htm2,独家专访林昊:一步一步了解Java模块化 http://developer.51cto.com/art/201001/181503.htmleekiang 2011-03-05 00:12 发表评论

View Article

Image may be NSFW.
Clik here to view.

Java字符串

String s1="ab";String s2="a"+"b";System.out.println(s1==s2);//trueString s1 = "abc";String s2 = "ab";String s3 = s2 + "c";System.out.println((s1 == s3));//falseString s1 = "abc"; final String s2 =...

View Article
Browsing all 31 articles
Browse latest View live