摘要: /** * 单例模式之懒汉模式且线程安全 * @author Administrator * 1.构造器私有化 * 2.定义一个本类类型的私有静态属性 * 3.提供一个获取该对象的公开静态方法 */class ThreadR{ private static ThreadR threadR; private ThreadR(){ } public static ThreadR getInstance(){ //这里通过双重判断的形式解决了效率的问题 if(threadR == null){ //这里的锁是字节码文件对象 synchronized(ThreadR.class)... 阅读全文
posted @ 2014-03-11 21:59 lxricecream 阅读(201) 评论(0) 推荐(0)
摘要: 定义:1.进程:进程是一个应用程序运行时的内存分配空间,它负责分配整个应用程序的内存空间;2.线程:其实就是进程中一个程序执行的控制单元,它负责的应用程序的执行顺序。创建线程的两种方式和使用方法:public class ThreadTestDriver { public static void main(String[] args) { System.out.println(Thread.currentThread().getName()); //第一种方法 ThreadTest threadTest = new ThreadTest("firstThread"); th 阅读全文
posted @ 2014-03-10 20:20 lxricecream 阅读(227) 评论(0) 推荐(0)
摘要: import java.io.BufferedWriter;import java.io.File;import java.io.FileFilter;import java.io.FileWriter;import java.io.IOException;import java.util.ArrayList;import java.util.List;public class TestDriver { public static void main(String[] args) throws IOException { File file = new File("E:\\PROGR 阅读全文
posted @ 2014-03-10 15:52 lxricecream 阅读(394) 评论(0) 推荐(0)
摘要: public class TestDriver { public static void main(String[] args) throws IOException { File file = new File("e:\\test.config"); //模拟load()方法将指定流中的属性列表加载到properties中,指定文件必须是键值对形式 Properties ps = new Properties(); BufferedReader bufR = new BufferedReader(new FileReader(file)); String bufStr = 阅读全文
posted @ 2014-03-09 21:11 lxricecream 阅读(292) 评论(0) 推荐(0)
摘要: http://my.oschina.net/raining0822 阅读全文
posted @ 2014-03-07 19:44 lxricecream 阅读(96) 评论(0) 推荐(0)
摘要: /** * 自定义IO异常 * @author Administrator * */public class FileWriterIoException extends RuntimeException { private static final long serialVersionUID = -3105736191743754320L; public FileWriterIoException(String msg){ super(msg); }}调用的时候直接throw new FileWriterIoException("创建流错误!"); 阅读全文
posted @ 2014-03-06 22:33 lxricecream 阅读(143) 评论(0) 推荐(0)
摘要: import java.util.ArrayList;import java.util.Collection;import java.util.Iterator;public class ListTest { public static void main(String[] args) { Collection col = new ArrayList(); //集合只能存储引用数据类型,那这里为什么可以存基本数据类型,因为集合在此处将基本数据类型自动装箱 col.add(1); col.add(2); col.add(3); col.add(5); //集合引用调用自己的迭代器... 阅读全文
posted @ 2014-03-05 16:48 lxricecream 阅读(833) 评论(0) 推荐(0)
摘要: import java.io.BufferedReader;import java.io.BufferedWriter;import java.io.FileWriter;import java.io.IOException;import java.io.InputStreamReader;public class BufTest { public static void main(String[] args) { /** * 创建一个文本,并且通过控制台写入文本 * 步骤: * 1.首先我们要将控制台输入的二进制转换成字符,然后通过BufferedReader读入缓冲区 *... 阅读全文
posted @ 2014-03-04 10:30 lxricecream 阅读(579) 评论(0) 推荐(0)
摘要: public class JdbcTest { public static void main(String[] args){ int[] arr = {1,2,3,4,5,6,7,8}; int result = searchHalf_2(arr, 5); System.out.println(result); } /** * 二分查找法(要求待查表为有序表) * @param arr 数组 * @param key 要查找的数 * @return 返回查找的数在数组中的索引位置 */ public static int searchHalf_2(int[] arr, int... 阅读全文
posted @ 2014-02-25 08:27 lxricecream 阅读(193) 评论(0) 推荐(0)
摘要: 首先 pinyin4j 是一个流行的java库,它可以帮助我们将 汉字转成对应的拼音。http://blog.csdn.net/pathuang68/article/details/6692882 阅读全文
posted @ 2014-01-06 19:40 lxricecream 阅读(134) 评论(0) 推荐(0)