2018年3月15日
摘要: public class TestDom4j { Document doc = null; //初始化,给doc指定路径 public TestDom4j() { SAXReader reader = new SAXReader(); try { doc = reader.read("src/Pho 阅读全文
posted @ 2018-03-15 23:07 00011101 阅读(114) 评论(0) 推荐(0) 编辑
  2018年3月12日
摘要: 需求:写一个闹钟程序,闹钟每隔2秒响一次,每次响5声,闹钟响铃后1秒,人将闹钟关闭.public class People implements Runnable { private String name; private Clock c; public People(String name, C 阅读全文
posted @ 2018-03-12 21:48 00011101 阅读(124) 评论(0) 推荐(0) 编辑
  2018年3月9日
摘要: 厨师作为生产者,每做一道菜,消费者就消灭一道菜;dish作为一个共有属性 public class Cooker implements Runnable { private String name; private Dish d; private String food; public String 阅读全文
posted @ 2018-03-09 23:11 00011101 阅读(153) 评论(0) 推荐(0) 编辑
摘要: 线程死锁会不断消耗资源,禁止使用。本文纯属娱乐。 在使用synchronized嵌套的时候很容易出现死锁现象,因此慎用synchronized嵌套。 public class TestDeadLock { public static void main(String [] args) { new T 阅读全文
posted @ 2018-03-09 21:19 00011101 阅读(109) 评论(0) 推荐(0) 编辑
  2018年3月5日
摘要: public class TestFileInputStream { public static void main(String [] args) { //读取指定文件中内容,并在控制台输出 FileInputStream fis = null; byte[] b = new byte[1024] 阅读全文
posted @ 2018-03-05 21:50 00011101 阅读(3788) 评论(0) 推荐(0) 编辑
  2018年3月3日
摘要: public class TestFile { public static void main(String [] args) { //遍历文件夹中文件名称,若文件夹中还存有文件夹,递归读取文件夹名称 File file = new File("D:\\javafile"); //假设文件保存在D: 阅读全文
posted @ 2018-03-03 23:00 00011101 阅读(183) 评论(0) 推荐(0) 编辑