Javaでexecメソッドを使用して再帰的なタッチを実行する方法はありますか?
目標は、リロード時にサイトのディレクトリにアクセスする単純な Web ページをセットアップして、設計がキャッシュが発生しないことを保証できるようにすることです。助けてください!!!
これは私がこれまでに持っていたもので、私のjspでは機能していません:
<%@ page import="java.io.BufferedReader,java.io.File,java.io.FileWriter, java.io.IOException, java.io.InputStreamReader, java.util.Map" %>
<%
String s = null;
// system command to run
String cmd = "find /home/abcdefg/ -exec touch {} \\;";
// set the working directory for the OS command processor
File workDir = new File("/home/ss/public_html/ss");
try {
Process p = Runtime.getRuntime().exec(cmd, null, workDir);
int i = p.waitFor();
if (i == 0){
BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
// read the output from the command
while ((s = stdInput.readLine()) != null) {
System.out.println(s);
}
}
else {
BufferedReader stdErr = new BufferedReader(new InputStreamReader(p.getErrorStream()));
// read the output from the command
while ((s = stdErr.readLine()) != null) {
System.out.println(s);
}
}
}
catch (Exception e) {
System.out.println(e);
}
%>