当前位置:秒懂库 > IT科技 > java代码
手机版

java代码

来源:秒懂库 阅读:1.68W 次
品牌型号:联想 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代码

本文链接:https://www.miaodongku.com/itkj/1r70r1.html

Copyright © 2024. 秒懂库 All right reserved. 黑ICP备20202358号-2

文字美图素材,版权属于原作者。部分文章内容由网友提供推送时因种种原因未能与原作者联系上,若涉及版权问题,敬请原作者联系我们,立即处理。