下载此文档

非常有用的java代码段.doc


文档分类:IT计算机 | 页数:约17页 举报非法文档有奖
1/17
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/17 下载此文档
文档列表 文档介绍
20非常有用的Java程序片段(1)
2013-06-14 14:57 陈皓酷壳网 我要评论(0) 字号:T | T
下面是20个非常有用的Java程序片段,希望能对你有用。
AD:2013大数据全球技术峰会课程PPT下载
下面是20个非常有用的Java程序片段,希望能对你有用。
1. 字符串有整型的相互转换
String a = (2);   //integer to numeric string   
int i = (a); //numeric string to an int  
2. 向文件末尾添加内容
BufferedWriter out = null;   
try {   
    out = new BufferedWriter(new FileWriter(”filename”, true));   
    (”aString”);   
} catch (IOException e) {   
    // error processing code   
} finally {   
    if (out != null) {   
        ();   
    }   
}  
3. 得到当前方法的名字
String methodName = ().getStackTrace()[1].getMethodName();  
4. 转字符串到日期
 = ().parse(date String);  
或者是:
SimpleDateFormat format = new SimpleDateFormat( "" );   
Date date = ( myString );  
5. 使用JDBC链接Oracle
public class OracleJdbcTest   
{   
    String driverClass = "";   
   
    Connection con;   
   
    public void init(FileInputStream fs) throws ClassNotFoundException, SQLException, FileNotFoundException, IOException   
    {   
        Properties props = new Properties();   
        (fs);   
        String url = ("");   
        String userName = ("");   
        String password = ("");   
        (driverClass);   
   
        con=(url, userName, password);   
    }   
   
    public void fetch() throws SQLException, IOException   
    {   
        PreparedStatement ps = ("select SYSDATE from dual");   
        ResultSet rs = ();   
   
        while (())   
        {   
            // do the thing you do   
        }   
        ();   
        ();   
    }   
   
    public static void main(String[] args)   
    {   
        OracleJ

非常有用的java代码段 来自淘豆网m.daumloan.com转载请标明出处.

相关文档 更多>>
非法内容举报中心
文档信息
  • 页数17
  • 收藏数0 收藏
  • 顶次数0
  • 上传人mh900965
  • 文件大小109 KB
  • 时间2017-11-17