当前位置:懂科普 >

IT科技

> java代码

java代码

品牌型号:联想 YOGA 14c/系统版本:windows7

Java常用的代码有

1、字符串整型互相转换

String a = String.valueOf(2); //integer to numeric string   int i = Integer.parseInt(a); //numeric string to an int 

2、字符串转日期

String methodName = Thread.currentThread().getStackTrace()[1].getMethodName(); 

3、得到当前方法的名字

String methodName = Thread.currentThread().getStackTrace()[1].getMethodName(); 

4、把 Java util.Date 转成 sql.Date

java.util.Date utilDate = new java.util.Date();  java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime()); 

5、向文件末尾添加内容

BufferedWriter out = null;  try {    out = new BufferedWriter(new FileWriter(”filename”, true));    out.write(”aString”);  } catch (IOException e) {    // error processing code  } finally {    if (out != null) {      out.close();    }  } 

java代码

标签: java 代码
  • 文章版权属于文章作者所有,转载请注明 https://dongkepu.com/itkeji/4n7rn4.html