java 调用shell命令cp
来源:互联网 发布:sst nc数据下载 编辑:程序博客网 时间:2024/06/05 04:23
其他命令可以直接用string ,cp命令要用string[],原因不清楚
package com;import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.util.ArrayList;import java.util.List;public class Test { public static void main(String args[]) { Process process = null; List<String> processList = new ArrayList<String>(); String[] command = new String[] { "sh", "-c", "/bin/cp /data1 /data2" }; StringBuffer sb = new StringBuffer(); for (int i = 0; i < command.length; i++) { sb.append(command[i]); } String s = sb.toString(); System.out.println("command:" + s); try { process = Runtime.getRuntime().exec(command); BufferedReader input = new BufferedReader(new InputStreamReader( process.getInputStream())); String line = ""; while ((line = input.readLine()) != null) { processList.add(line); } input.close(); } catch (IOException e) { e.printStackTrace(); } for (String line : processList) { System.out.println(line); } }}
阅读全文
0 0
- java 调用shell命令cp
- shell命令 cp
- shell中cp命令
- shell命令之cp
- shell命令--cp
- Java 调用 Shell 命令
- Java 调用 Shell 命令
- java调用shell命令
- Java 调用 Shell 命令
- java 调用shell命令
- shell cp命令参数详解
- (8) linux shell 命令 -- cp
- Java 调用Liunx shell 命令
- java -cp 命令使用
- java的cp命令
- java的cp命令
- JAVA CP命令
- JAVA cp 命令
- xcode 下 ffmpeg soundtouch faac x264 libyuv lame 一次打包armv7 armv7s arm64
- Spark streaming不同数据来源(socket套接字、hdfs目录)和存储位置(hdfs、本地)的java代码
- Tomcat的性能与最大并发(1000)
- OSI七层模型和TCP/IP五层模型详讲
- Python str 与 bytes 类型(Python2/3 对 str 的处理)
- java 调用shell命令cp
- 闭包小案例
- Python+caffe实现
- VUWE——又一个移动端Vue2组件库
- 进程间通信IPC、LPC、RPC
- win7安装vm12
- Android and Architecture(安卓和架构)
- Jenkins持续化构建Android项目(二)-构建Android项目生成apk(by 星空武哥)
- 看书笔记摘抄:python记录log的例子