
Core Java
追梦的程序猿
一天一点点
展开
-
Java使用TimerTask实现定时循环执行任务功能
package Test;import java.util.Timer;import java.util.TimerTask;public class Test { static boolean isEnd = false; //控制TimerTask的结束标识 static int count = 1; //循环计数器 static Timer timer = new Ti...原创 2019-08-14 09:28:27 · 2137 阅读 · 0 评论 -
Java使用FileWriter实现向文件末尾添加内容功能
private void saveResultToFile(String result) { //创建FileWriter、BufferedWriter FileWriter fw = null; BufferedWriter bufw = null; File file = new File("D:\\file.txt"); try {...原创 2019-08-14 15:51:14 · 2314 阅读 · 0 评论 -
Java使用Date类型相加实现日期时间设置功能
1.通过gettime()取出Date对应的毫秒值2.加上需要添加的毫秒值(需要用long类型,数值后要加“L”)3.使用setTime()设置新的Date数值实例Date buydate = new Date();//设置购买时间long time =buydate.getTime();//设置套餐到期时间time = time + 31*1*24*60*60*1000...原创 2019-08-14 16:15:03 · 1624 阅读 · 0 评论 -
Java使用注释标记过时方法
package Test;public class Test { @Deprecated public void oldMethod () { //过时方法示例 } public void newMethod() { //正常方法 } public static void main(String[] args) { Test test = new Test...原创 2019-08-15 10:40:24 · 3219 阅读 · 0 评论 -
Java 使用String类的indexOf方法实现字符串查找功能
// **** 将uri由“http://.../...”处理为“/...” ****String uri = request.uri();for (int i = 0; i < 2; i++) { uri = uri.substring(uri.indexOf("/") + 1);}uri = uri.substring(uri.indexOf("/"));...原创 2019-08-23 13:11:10 · 633 阅读 · 0 评论