java 调用you-get且可输出日志

public static void exeCmd(String commandStr,long detailId,String detailname) { 
BufferedReader br = null; 
try { 
Process p = Runtime.getRuntime().exec(commandStr); 
br = new BufferedReader(new InputStreamReader(p.getInputStream(),Charset.forName("utf-8"))); 
String line = null; 
StringBuilder sb = new StringBuilder(); 
while ((line = br.readLine()) != null) { 
sb.append(line + "\n"); 
System.out.println(line+"-----"+detailname); 

//System.out.println(sb.toString()); 
} catch (Exception e) { 
e.printStackTrace(); 
} finally { 
if (br != null){ 
try { 
br.close();
Moviedetail md=moviedetailService.findById(detailId);
md.setAddtime(new Date());
moviedetailService.update(md);
} catch (Exception e) { 
e.printStackTrace(); 



}
public static void main(String[] args) {
exeCmd("you-get https://v.douyu.com/show/lKg1VWRmb9QMGbNA",0l,"");
}
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页