向Java文件中添加文本 Updated: Thanks Simone for pointing to exception. I have changed the code. 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(); } } 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();}} 3. 获取Java现在正调用的方法名 String methodName = Thread.currentThread().getStackTrace()[1].getMethodName(); String methodName = Thread.currentThread().getStackTrace()[1].getMethodName (); 4. 在Java中将String型转换成Date型 java.util.Date = java.text.DateFormat.getDateInstance().parse(date String); java.util.Date = java.text.DateFormat.getDateInstance().parse(date String);or SimpleDateFormat format = new SimpleDateFormat( "dd.MM.yyyy" ); Date date = format.parse( myString ); SimpleDateFormat format = new SimpleDateFormat( "dd.MM.yyyy" );Date date = format.parse( myString ); 5. 通过Java JDBC链接Oracle数据库 public class OracleJdbcTest { 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(); } public static void main(String[] args) { OracleJdbcTest test = new OracleJdbcTest(); test.init(); test.fetch (); } }
![txt](https://img-home.csdnimg.cn/images/20210720083642.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![txt](https://img-home.csdnimg.cn/images/20210720083642.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/ffa07bdf275a4c8e8cc04bea02c10914_ya7512196.jpg!1)
- 粉丝: 2
- 资源: 22
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)