1. 字符串有整型的相互转换 String a = String.valueOf(2); //integer to numeric stringint i = Integer.parseInt(a); //numeric string to
1. 字符串有整型的相互转换
String a = String.valueOf(2); //integer to numeric stringint i = Integer.parseInt(a); //numeric string to an int
BufferedWriter out = ;try {out = new BufferedWriter(new FileWriter(”filename”, true));out.write(”aString”);} catch (ioException e) {// error processing code} finally {if (out != ) {out.close;}}
String methodName = Thread.currentThread.getStackTrace[1].getMethodName;
java.util.Date = java.text.DateFORMat.getDateInstance.parse(date String);或者是:SimpleDateFormat format = new SimpleDateFormat( "yyyy-MM-dd" );Date date = format.parse( myString );
public classOracleJdbcTest{String driverClass = "oracle.jdbc.driver.OracleDriver";Connection con;public void init(FileInputStream fs) throws ClassNotFoundException, sqlException, FileNotFoundException, IOException{Properties props = new Properties;props.load(fs);String url = props.getProperty("db.url");String userName = props.getProperty("db.user");String passWord = props.getProperty("db.password");Class.forName(driverClass);con=DriverManager.getConnection(url, userName, password);}public void fetch throws SQLException, IOException{PreparedStatement ps = con.prepareStatement("select SYSDATE from dual");ResultSet rs = ps.executeQuery;while (rs.next){// do the thing you do}rs.close;ps.close;}publicstaticvoidmain(String[] args){OracleJdbcTest test = new OracleJdbcTest;test.init;test.fetch;}}
File dir = new File("directoryName");String children = dir.list;if (children == ) {// Either dir does not exist or is not a directory} else {for (int i=0; i < children.length; i++) {// Get filename of file or directoryString filename = children[i];}}// It is also possible to filter the list of returned files.// This example does not return any files that start with `.'.FilenameFilter filter = new FilenameFilter {public boolean accept(File dir, String name) {return !name.startsWith(".");}};children = dir.list(filter);// The list of files can also be retrieved as File objectsFile files = dir.listFiles;// This filter only returns directoriesFileFilter fileFilter = new FileFilter {public boolean accept(File file) {return file.isDirectory;}};files = dir.listFiles(fileFilter);
John B 12 Mary A 11 Simon A 18
1 public class PageBean {2 private int curPage; //当前页3 private int pageCount; //总页数4 private int rowsCount; //总行数5 private int pageSize=10; //每页多少行6789publicPageBean(int rows){1011 this.setRowsCount(rows);12 if(this.rowsCount % this.pageSize == 0){13 this.pageCount=this.rowsCount / this.pageSize;14 }15 else if(rows24 publicintgetCurPage {25 return curPage;26 }27publicvoidsetCurPage(int curPage) {28 this.curPage = curPage;
每天分享一点,每天进步一点,留个小尾巴《医院证明图片》
来源地址:https://blog.csdn.net/dageliuqing/article/details/127405259
--结束END--
本文标题: java代码大全及详解(Java 常用代码汇总)
本文链接: https://www.lsjlt.com/news/399085.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-04-01
2024-04-03
2024-04-03
2024-01-21
2024-01-21
2024-01-21
2024-01-21
2023-12-23
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0