![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
JAVA
文章平均质量分 55
fanrey123
这个作者很懒,什么都没留下…
展开
-
Java集合容器总结(ZZ)
按数据结构主要有以下几类: 1,内置容器:数组 2,list容器:Vetor,Stack,ArrayList,LinkedList, CopyOnWriteArrayList(1.5),AttributeList(1.5),RoleList(1.5),RoleUnresolvedList(1.5), ConcurrentLinkedQueue(1.5),ArrayBlockingQ...原创 2011-10-11 16:30:12 · 77 阅读 · 0 评论 -
Eclipse下运行System.getenv()返回null
在Eclipse下运行System.getenv("COM_TRUNK")返回null,在shell下运行则正常。在/etc/environment中添加COM_TRUNK=/home/ubuntu/com既可。原创 2012-09-22 18:01:59 · 1121 阅读 · 0 评论 -
emma doesn't coverage code with tests with @RunWith(PowerMockRunner.class);
被测试的class是VINESNodeAddressCollector:@RunWith(PowerMockRunner.class)//add following VINESNodeAddressCollector.class will make coverage not work, so comment out.@PrepareForTest({ApplicationRunne...原创 2012-09-14 17:03:38 · 291 阅读 · 0 评论 -
使用PowerMock导致的ClassCastException
使用PowerMock时遇到一些莫名其妙的问题,比如:java.lang.ClassCastException: com.sun.org.apache.xerces.internal.parsers.SAXParser cannot be cast to org.xml.sax.XMLReader事实上SAXParser实现了XMLReader接口,所以上面这个Exception说明他们被...原创 2012-09-07 16:02:33 · 769 阅读 · 0 评论 -
PowerMock incompatible with Mockito issue
Mock版本如下:Mockito version: 1.8.0PowerMock version: 1.4.6测试代码很简单,但运行到mockStatic时报错。import org.junit.Test;import org.junit.runner.RunWith;import static org.powermock.api.mockito.PowerMockit...原创 2012-09-07 09:55:14 · 496 阅读 · 1 评论 -
一个JTable相关的问题
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: -1 at java.util.Vector.elementAt(Unknown Source) at javax.swing.table.DefaultTableColumnModel.getColumn(Unknown Sou...原创 2012-08-06 18:33:12 · 180 阅读 · 0 评论 -
Java SPI学习
Java1.6开始提供了ServiceLoader类来支持SPI。1. 写好接口:public interface Service1 { public void sayHello();}2. 两个实现类:public class ServiceImpl implements Service1 { public void sayHello(){ Sy...原创 2012-07-22 16:16:06 · 103 阅读 · 0 评论 -
用jvmti调试java application: hello world 实现
1. 用C写一个动态链接库, 代码如下:ubuntu@ubuntu-VirtualBox:~$ cat agent.cpp#include #include #include #include #include #include #include #include #include JNIEXPORT jint JNI...原创 2012-07-03 11:57:35 · 267 阅读 · 0 评论 -
8000 nodes continously disconnect in large network environment
根本原因是socket资源不足,导致连接失败, 下面是对exception的分析:1. java.net.BindException: Address already in use. It may be caused by the port resources are not released quickly after we call socket.close(), but be in ...原创 2012-06-21 18:16:18 · 123 阅读 · 0 评论 -
a Java-level deadlock example
Found one Java-level deadlock:============================="StartStopServicePool-5 - 5165": waiting to lock monitor 0x0816cc20 (object 0xb37eb908, a sun.misc.Launcher$AppClassLoader), which ...原创 2012-05-25 12:08:15 · 184 阅读 · 0 评论 -
java Semaphore 实例 -- Hungry Birds
The Hungry Birds Problem (one producer - multiple consumers)Given are n baby birds and one parent bird. The baby birds eat out of a common dish that initially contains W worms. Each baby bird repea...原创 2012-05-09 12:55:36 · 94 阅读 · 0 评论 -
Java Lock 实例 -- 实现简单的tee
Develop a parallel multithreaded program (in C using Pthreads, or in Java) that implements the Unix tee command, which is invoked as follows: tee filenameThe command reads the standard input and ...原创 2012-05-08 21:36:56 · 346 阅读 · 0 评论 -
Java synchronized实例 -- Hungry Bird
Given are n baby birds and one parent bird. The baby birds eat out of a common dish that initially contains W worms. Each baby bird repeatedly takes a worm, eats it, sleeps for a while, takes another ...原创 2012-05-08 21:25:32 · 90 阅读 · 0 评论 -
replaceAll()中正则表达式的应用
(?i): 忽略大小写;(?m): 在这种模式下,'^'和'$'分别匹配一行的开始和结束. 缺省为匹配整个字符串的开始和结束;(?s): 在这种模式下,表达式'.'可以匹配任意字符,包括表示[b]一行的结束符[/b]。默认情况下,表达式'.'不匹配行的结束符。测试代码:String fromStr = "Limited\n\n this is a limited CDB cle...原创 2011-10-18 11:13:40 · 740 阅读 · 0 评论 -
java socket example
ObjectServer.java[code="java"]import java.io.ObjectInputStream;import java.io.ObjectOutputStream;import java.net.ServerSocket;import java.net.Socket;public class ObjectServer { publi...原创 2013-07-17 17:08:48 · 108 阅读 · 0 评论