|
@@ -19,6 +19,7 @@ import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
|
import java.io.*;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
@@ -457,4 +458,43 @@ public class CameraUtil {
|
|
|
flvPath = caneraConfig.getFlvPath();
|
|
|
filePath = caneraConfig.getFilePath();
|
|
|
}
|
|
|
+
|
|
|
+ public void deleteFlv() throws IOException, InterruptedException {
|
|
|
+ SimpleDateFormat s = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ Date date = new Date();
|
|
|
+ Calendar calendar = new GregorianCalendar();
|
|
|
+ calendar.setTime(date);
|
|
|
+ calendar.add(calendar.DATE, -1); //把日期往后增加一天,整数 往后推,负数往前移动
|
|
|
+ date = calendar.getTime(); //这个时间就是日期往后推一天的结果
|
|
|
+ String path = BaseConfig.getProfile() + "/flv/" + DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, date);
|
|
|
+ File file = new File(path);
|
|
|
+ if (file.exists()) {
|
|
|
+ List<String> rspList = new ArrayList<String>();
|
|
|
+ Process proc = Runtime.getRuntime().exec("/bin/bash", null, null);
|
|
|
+ BufferedReader in = new BufferedReader(new InputStreamReader(proc.getInputStream()));
|
|
|
+ PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(proc.getOutputStream())), true);
|
|
|
+ String commit = " rm -rf " + path;
|
|
|
+ List<String> commands = new ArrayList<>();
|
|
|
+
|
|
|
+ // 删除
|
|
|
+ commands.add(commit);
|
|
|
+ for (String line : commands) {
|
|
|
+ out.println(line);
|
|
|
+ }
|
|
|
+ out.println("exit");// 这个命令必须执行,否则in流不结束。
|
|
|
+ String rspLine = "";
|
|
|
+ while ((rspLine = in.readLine()) != null) {
|
|
|
+ System.out.println(rspLine);
|
|
|
+ rspList.add(rspLine);
|
|
|
+ }
|
|
|
+ int i = proc.waitFor();
|
|
|
+ log.info("执行结果:{}", i);
|
|
|
+
|
|
|
+ in.close();
|
|
|
+ out.close();
|
|
|
+ proc.destroy();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|