摘要: 阅读全文
posted @ 2014-09-03 16:16 IT稻草 阅读(1048) 评论(0) 推荐(0)
摘要: import java.text.SimpleDateFormat;import java.util.Calendar;方法一:SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");String ly_time = sdf.format(new java.util.Date()); System.out.println("现在时间是:"+ly_time);结果:现在时间是:2008-11-28 14:19:49方法二:String ly_time = new SimpleDa 阅读全文
posted @ 2013-03-26 09:42 IT稻草 阅读(646) 评论(0) 推荐(0)
摘要: 有两种方法:方法一:用java.util.Date类来实现,并结合java.text.DateFormat类来实现时间的格式化,看下面代码:import java.util.*;import java.text.*;//以下默认时间日期显示方式都是汉语语言方式//一般语言就默认汉语就可以了,时间日期的格式默认为MEDIUM风格,比如:2008-6-16 20:54:53//以下显示的日期时间都是再Date类的基础上的来的,还可以利用Calendar类来实现见类TestDate2.javapublic class TestDate { public static voidmain(String[ 阅读全文
posted @ 2013-03-26 09:38 IT稻草 阅读(1077) 评论(0) 推荐(0)
摘要: public Student[] readFile(String path) { String str = null;String[] array = null;Student[] stus = new Student[4]; //Student 持久化对象类int i = 0;FileReader file = null;BufferedReader read = null;try {file = new FileReader(path); //path 指定文件的路径read = new BufferedReader(file);while ((str = read.readLine()) 阅读全文
posted @ 2013-03-06 14:29 IT稻草 阅读(915) 评论(0) 推荐(0)
摘要: List,Set转换为数组的方法。toArray函数有两种形式,一种无参数,一种带参数,注意带参数形式中,要指明数组的大小。程序代码:List----数组Set----数组 public void convertCollectionToArray() { List list = new ArrayList(); Object[] objectArray1 = list.toArray(); String[] array1 = list.toArray(new String[list.size()]); Set set = new HashSet(); Object[] objectArray2 阅读全文
posted @ 2013-03-06 14:27 IT稻草 阅读(217) 评论(0) 推荐(0)
摘要: 1、新建目录 <%@ page contentType="text/html;charset=gb2312"%> <% String filePath="c:/aaa/"; filePath=filePath.toString();//中文转换 java.io.File myFilePath=new java.io.File(filePath); if(!myFilePath.exists()) myFilePath.mkdir(); %>2、新建文件 <%@ page contentType="text/html 阅读全文
posted @ 2012-11-24 09:16 IT稻草 阅读(160) 评论(0) 推荐(0)
摘要: 1.super()与this()的区别? This():当前类的对象,super父类对象;Super():在子类访问父类的成员和行为,必须受类继承规则的约束,而this他代表当前对象,当然所有的资源都可以访问,在构造函数中,如果第一行没有写super(),编译器会自动插入.但是如果父类没有不带参数的构造函数,或这个函数被私有化了(用private修饰).此时你必须加入对父类的实例化构造.而this就没有这个要求,因为它本身就进行实例化的构造,而在方法中super和this使用的方法就差不多了.只不过super要考虑是否能访问其父类的资源.。2.作用域public,protected,priv. 阅读全文
posted @ 2012-11-21 17:11 IT稻草 阅读(198) 评论(0) 推荐(0)