網站首頁 學習教育 IT科技 金融知識 旅遊規劃 生活小知識 家鄉美食 養生小知識 健身運動 美容百科 遊戲知識 綜合知識
當前位置:趣知科普吧 > IT科技 > 

java代碼

欄目: IT科技 / 發佈於: / 人氣:1.55W
品牌型號:聯想 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代碼

Tags:java 代碼