
j2se
文章平均质量分 87
王奕然
这个作者很懒,什么都没留下…
展开
-
解压缩带有中文名文件的ZIP包 .
java.util.zip.ZipInputStream和java.util.zip.ZipOutputStream压缩和解压带有中文名文件的ZIP包时,会报如下异常:java.lang.IllegalArgumentException at java.util.zip.ZipInputStream.getUTF8String(ZipInputStream.java:293) at j转载 2013-01-25 15:17:36 · 1580 阅读 · 0 评论 -
Interview stuff about String class in java
All of us must have gone though some common questions related to String class in java. These questions range from immutability to memory leak issues. I will try to cover such questions in this pos转载 2013-05-01 14:39:52 · 538 阅读 · 0 评论 -
How hashmap works in java
Most of you will agree that HashMap is most favorite topic for discussion in interviews now-a-days. I have gone through several discussions with my colleagues time to time and it really helped. Now,转载 2013-05-01 11:27:33 · 564 阅读 · 0 评论 -
Performance considerations for keySet() and entrySet() of Map
First of all, this depends entirely on which type of Map you're using. But since the JavaRanch thread talks about HashMap, I'll assume that that's the implementation you're referring to. And lets assu转载 2013-05-02 09:54:12 · 569 阅读 · 0 评论 -
Nested Classes嵌套类
The Java programming language allows you to define a class within another class. Such a class is called anested class and is illustrated here:class OuterClass { ... class NestedClass {原创 2013-05-03 11:03:39 · 816 阅读 · 0 评论 -
When to use comparable and comparator interfaces in java
You must have been came across the situation where you have to sort a collection of objects by a certain rule. And if you are working on a domain where people are your main entities, you will encounte转载 2013-05-03 13:22:20 · 782 阅读 · 0 评论 -
stack and heap
2.5.2. Java Virtual Machine Stacks Each Java Virtual Machine thread has a privateJava Virtual Machine stack, created at the same time as the thread.A Java Virtual Machine stack stores frames (§2转载 2013-05-09 10:25:17 · 726 阅读 · 0 评论 -
分配给单链表的内存储单元地址必须是连续的吗
单链表中结点值与指针在内存中是连续的吗对于同一个结点,值与指针是一块分配的,是连续的。不同结点的内存地址可能相邻也可能跳跃。转自:http://zhidao.baidu.com/question/508898073.html分配给单链表内存单元地址必须是连续的,转自:http://wenku.baidu.com/view/cec105d6b9f3f90f76c61bc1.html转载 2013-05-09 11:10:45 · 10995 阅读 · 0 评论 -
Java Final Keyword
A java variable can be declared using the keyword final. Then the final variable can be assigned only once.A variable that is declared as final and not initialized is called a blank final variable. A转载 2013-06-15 11:08:24 · 584 阅读 · 0 评论 -
How do I use locales and resource bundles to internationalize my application?
How do I use locales and resource bundles to internationalize my application?Author: Deron ErikssonDescription: This Java tutorial describes how to use locales and resource bundles to internat转载 2013-07-22 14:27:54 · 696 阅读 · 0 评论 -
3 Ways of JDK Source Code Attachment in Eclipse
You wanna look at a JVM class while you are coding and you cannot. Here is the solution.First of all, download your related JDK source code files unless you already have it. In general, source cod转载 2013-07-28 21:02:43 · 674 阅读 · 0 评论 -
java(位运算符)两个大于(小于)号,<<,>>
今天群里一哥们,突然问了一下,3年没接触这个了,忽然有点生疏了。比如 : 2意思是:把2换成2进制(.....0 0 0 0 0 1 0),然后那么后面是5的话,就是移动5位,那么结果就是--- 64 了。语法格式: 需要位移的数字 >) 位移的位数转自:http://lienan123.blog.163.com/blog/static/303581082转载 2013-08-15 18:15:26 · 11644 阅读 · 0 评论 -
Top 20 Java Websites
Here’s the best 20 Java websites in my collections, which provides latest Java news, articles and tutorials. If you have other great Java websites, please leave a comment to share with others.P.S转载 2013-09-01 20:34:33 · 722 阅读 · 0 评论 -
学习jar命令 创建和解压jar文件包
java编程中每天都用不少jar文件,项目开发中不停地导包,在忙完了一天的工作,放下那些复杂的业务实现,不仅想问这些jar包怎么生成的,jar包有哪些独特的地方等等。 原来这些经常见到的jar包是jar命令生成的,java语言为我们在安装jdk的时候,就随jdk为我们在bin目录中安装好了,在windows系统中是jar.exe程序,Linux系统中为jar文件。转载 2013-09-04 21:37:52 · 848 阅读 · 0 评论 -
How To Create XML File In Java – (DOM Parser)
DOM provides many handy classes to create XML file easily. Firstly, you have to create a Document withDocumentBuilder class, define all the XML content – node, attribute with Element class. In last, u转载 2014-02-27 17:48:04 · 612 阅读 · 0 评论 -
How To Execute Shell Command From Java
In Java, you can use Runtime.getRuntime().exec to execute external shell command : p = Runtime.getRuntime().exec("host -t a " + domain); p.waitFor(); BufferedReader reader =转载 2014-02-27 17:49:45 · 1152 阅读 · 0 评论 -
How To Delete Directory In Java
To delete a directory, you can simply use the File.delete(), but the directory must be empty in order to delete it.Often times, you may require to perform recursive delete in a directory, which me转载 2014-02-27 17:54:17 · 553 阅读 · 0 评论 -
Working with hashCode and equals methods in java
In this post, i will point out my understanding about hashCode() and equals() method. I will talk about their default implementation and how to correctly override them. I will also write about impleme转载 2013-05-01 13:57:11 · 619 阅读 · 0 评论 -
Top 20 Java Websites
Here’s the best 20 Java websites in my collections, which provides latest Java news, articles and tutorials. If you have other great Java websites, please leave a comment to share with others.P.S转载 2013-04-30 00:46:52 · 3012 阅读 · 0 评论 -
Java的synchronized关键字:同步机制总结
JAVA中synchronized关键字能够作为函数的修饰符,也可作为函数内的语句,也就是平时说的同步方法和同步语句块。搞清楚synchronized锁定的是哪个对象,就能帮助我们设计更安全的多线程程式。不久前用到了同步,现在回过头来对JAVA中的同步做个总结,以对前段时间工作的总结和自我技术的条理话。JAVA的synchronized关键字能够作为函数的修饰符,也可作为函数内的语转载 2013-04-28 10:51:18 · 488 阅读 · 0 评论 -
java中字符串的编码解码问题
1.将字符串转换成byte数组再恢复:byte[] getBytes(String charsetName)String(byte[] bytes, String charsetName)或getBytes()String(byte[] bytes)2.使用String sun.misc.BASE64Encode.encode(byte[] b)byte[] String转载 2013-01-25 18:22:08 · 826 阅读 · 0 评论 -
动态创建web路径,并存储临时上传文件
首先介绍 String path = ServletActionContext.getServletContext().getRealPath("/WEB-INF/");方法,可以找到动态的和"/WEB-INF/“相对的路径,然后按着日期格式创建文件夹SimpleDateFormat simpleDateFormat = new SimpleDateFormat("/yyyy/MM/dd"原创 2013-01-27 21:56:27 · 1702 阅读 · 0 评论 -
uuid 生成主键
UUID(全球唯一编号) UUID是一个128位长的数字,一般用16进制表示。算法的核心思想是结合机器的网卡、当地时间、一个随即数来生成UUID。从理论上讲,如果一台机器每秒产生10000000个UUID,则可以保证(概率意义上)3240年不重复。 UUID是1.5中新增的一个类,在java.util下,用它可以产生一个号称全球唯一的ID. UUID是指在一台机器转载 2013-01-28 09:41:17 · 1183 阅读 · 0 评论 -
java.lang.Class cannot be cast to java.lang.reflect.ParameterizedType
抛出异常是因为没有在子类指定泛型类型原创 2013-02-06 14:03:11 · 500 阅读 · 0 评论 -
泛型如何获取类
(ParameterizedType) getClass().getGenericSuperclass().getActualTypeArguments()[0]得到的是什么?这种写法一般都会在基类中看到,而且是使用了JAVA泛型的,比如我们J2EE中的BaseDAO什么的,请看代码,其实简写了,分开写就明了了。基类:import java.lang.reflect.Param转载 2013-02-06 14:00:42 · 653 阅读 · 0 评论 -
Java注解
一、什么是JAVA的注解? 注解,顾名思义就是对某种事物添加一个注释说明的意思,标注某种事物的特征以及形态,供日后其它人遇到该事物时有一个直观的认识。JAVA注解又叫JAVA标注,JAVA语言提供一套机制,可以在包、类(包括接口、枚举、注解)、方法、字段(包括常量)、方法参数、局部变量、构造器和注解这些元素上添加标注(即为这些元素附上一些标识信息),在某些业务需要的情况下,可以通过JA转载 2013-02-19 12:41:58 · 666 阅读 · 0 评论 -
BeanUtils.copyProperties时日期的拷贝
首先定义一个Converter的Date实现类import java.util.Date;import org.apache.commons.beanutils.ConversionException;import org.apache.commons.beanutils.Converter;import cn.sh.cares.commons.excel.util.E转载 2013-02-19 09:26:35 · 3723 阅读 · 0 评论 -
java和数据库日期格式表示
java中 :yyyy-MM-dd HH:mm:ss 二十四小时制 yyyy-MM-dd hh:mm:ss十二小时制 oracle中: to_date('2011-10-01 14:00:00','yyyy-mm-dd HH24:mi:ss'); to_date('2011-10-01 14:00:00','yyyy-mm-转载 2013-02-20 12:52:40 · 460 阅读 · 0 评论 -
commons.beanutils.ConversionException: No value specified解决办法
当用到了时间等非内置对象时,如果对象为NULL则,会出现此异常。最简单的方法就是保证非内置对象不为NULL。还有其它高手给出的修改commons包相关源码的解决方案,也一并给出:时间解决方案:方案一:问题解决: 读了他的源程序,发现日期java.sql.date主要是用org.apache.commons.beanutils.converters.SqlDateCo转载 2013-02-20 13:36:48 · 430 阅读 · 0 评论 -
如何使用List.toArray()转换为数组对象
在程序中,我们往往习惯使用List这种集合类,但是程序中却要求需要传递一个数组,我们可以这样实现:Long [] l = new Long[list.size()];for(int i=0;i l[i] = (Long) list.get(i);这样的代码看上去似乎繁琐了一些,实际上List已经为我们提供了toArray()方法,但是如果使用时不注意,就转载 2013-02-23 10:56:18 · 424 阅读 · 0 评论 -
How to configure environment to use JavaMail?
11down vote accepted If you're looking for a tutorial to configure an SMTP server, you shouldn't be looking for JavaMail. Simply look for a tutorial on your server of choice (Kerio, for转载 2013-03-14 21:59:05 · 583 阅读 · 0 评论 -
javamail发送网页邮件,且有中文
public void sendMail() throws IOException { // create some properties and get the default Session Properties props = new Properties(); props.put("mail.smtp.host", "smtp.sina.com.cn"); props.se原创 2013-03-15 15:14:30 · 985 阅读 · 0 评论 -
TreeMap
treemapA Red-Black tree based NavigableMap implementation. The map is sorted according to the natural ordering of its keys, or by a Comparator provided at map creation time, depending on which原创 2013-04-04 09:55:39 · 549 阅读 · 0 评论 -
Synchronized Statements作用
先来看下lock的作用intrinsic Locks and SynchronizationSynchronization is built around an internal entity known as the intrinsic lock ormonitor lock. (The API specification often refers to this ent原创 2013-04-27 15:34:22 · 603 阅读 · 0 评论 -
Java Deadlock Example – How to analyze deadlock situation
Deadlock is a programming situation where two or more threads are blocked forever, this situation arises with at least two threads and two or more resources. Here I have written a simple program that转载 2013-04-28 09:29:05 · 797 阅读 · 0 评论 -
Locks In Synchronized Methods
Locks In Synchronized MethodsWhen a thread invokes a synchronized method, it automatically acquires the intrinsic lock for that method's object and releases it when the method returns. The lock rele原创 2013-04-28 10:21:21 · 505 阅读 · 0 评论 -
Java Enum implementing an Interface
In this tutorial you will learn how to implement an Interface with an Enum in Java.1. IntroductionSome developers are not aware of this fact but we can implement Interfaces with Enums in Jav转载 2014-03-14 09:16:28 · 998 阅读 · 0 评论