往D:\\apache-tomcat-8.0.9\\webapps\\ROOT\\testlog\\ajax-1.txt下写内容
2016-09-29 14:45
190 查看
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.text.SimpleDateFormat;
public class Main {
public static void writeTime(){
new Thread(new Runnable() {
@Override
public void run() {
while (true) {
try {
System.out.println("往D:\\apache-tomcat-8.0.9\\webapps\\ROOT\\testlog\\ajax-1.txt下写内容!");
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS"); //定义想要的格式
String time = simpleDateFormat.format(System.currentTimeMillis());
File f = new File("D:\\apache-tomcat-8.0.9\\webapps\\ROOT\\testlog\\ajax-1.txt");
BufferedWriter bw = new BufferedWriter(new FileWriter(f, true));
bw.write(time);
bw.newLine();
bw.close();
} catch (IOException e) {
e.printStackTrace();
}
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}).start();
}
public static void main(String[] args) {
/*int a=0,c=2;
do{
--c;
a=0-a;
a++;
System.out.println(c);
}while(a<0);*/
writeTime();
}
}
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.text.SimpleDateFormat;
public class Main {
public static void writeTime(){
new Thread(new Runnable() {
@Override
public void run() {
while (true) {
try {
System.out.println("往D:\\apache-tomcat-8.0.9\\webapps\\ROOT\\testlog\\ajax-1.txt下写内容!");
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS"); //定义想要的格式
String time = simpleDateFormat.format(System.currentTimeMillis());
File f = new File("D:\\apache-tomcat-8.0.9\\webapps\\ROOT\\testlog\\ajax-1.txt");
BufferedWriter bw = new BufferedWriter(new FileWriter(f, true));
bw.write(time);
bw.newLine();
bw.close();
} catch (IOException e) {
e.printStackTrace();
}
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}).start();
}
public static void main(String[] args) {
/*int a=0,c=2;
do{
--c;
a=0-a;
a++;
System.out.println(c);
}while(a<0);*/
writeTime();
}
}
相关文章推荐
- 【tomcat】FileNotFoundException: C:\Program Files\Java\apache-tomcat-8.5.11-geneshop3\webapps\ROOT\index.html (拒绝访问。)
- Unable to load configuration. - action - file:/C:/apache-tomcat-7.0.75/webapps/ROOT/WEB-INF/classes/
- Tomcat启动时出现java.lang.IllegalArgumentException: Document base D:\apache-tomcat-6.0.20\webapps\XXX doe
- java.lang.IllegalArgumentException: Document base D:/appservers/apache-tomcat-6.0.20/webapps/megaey
- org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [/Users/lonecloud/tomcat/apache-tomcat-7.0.70 2/webapps/myproject/WEB-INF/classes/cn/lone
- java.lang.IllegalArgumentException: Document base D:\apache-tomcat-6.0.20\webapps\bookstore does not
- Unable to load configuration. - action - file:/D:/apache-tomcat-7.0.68/webapps/SSHDemo/WEB-INF/class
- Tomcat 下的 webapps\ROOT 目录发布、访问关联
- Error deploying web application directory D:\apache-tomcat-8.0.26\webapps\servlet
- Tomcat启动时出现java.lang.IllegalArgumentException: Document base D:\apache-tomcat-6.0.20\webapps\XXX doe
- Tomcat学习—Tomcat7 修改/webapps/ROOT发布路径(Linux和windows环境)
- 导入项目启动报错Unexpectedexception parsing XML document from file[H:\software\apache-tomcat-7.0.77\webapps\
- Unable to load configuration. - action - file:/F:/apache-tomcat-7.0.27/webapps/CRM/WEB-INF/classes/s
- tomcat 下webapps root 404问题
- Document base E:\apache-tomcat-6.0.37(32)\webapps\xxx does not exist or is not a readable directory
- java.lang.IllegalArgumentException: Document base D:/appservers/apache-tomcat-6.0.20/webapps/megaeyes_enterprise_manager does no
- tomcat启动报错Document base D:\apache-tomcat-6.0.35\webapps\CelLoud does not exist or is n...
- java.lang.IllegalArgumentException: Document base D:\apache-tomcat-6.0.20\webapps\XXX错误
- 这个页面放在tomcat/webapps/ROOT/下可以查看内存堆栈,对于分析定位性能问题,很有效果
- Document base D:\devTools\apache-tomcat-6.0.51\webapps\AppService does not exist or is not a readable directory