本文整理汇总了Java中eu.chainfire.libsuperuser.StreamGobbler.OnLineListener类的典型用法代码示例。如果您正苦于以下问题:Java OnLineListener类的具体用法?Java OnLineListener怎么用?Java OnLineListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OnLineListener类属于eu.chainfire.libsuperuser.StreamGobbler包,在下文中一共展示了OnLineListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processLine
import eu.chainfire.libsuperuser.StreamGobbler.OnLineListener; //导入依赖的package包/类
/**
* Process a normal STDOUT/STDERR line
*
* @param line Line to process
* @param listener Callback to call or null
*/
private synchronized void processLine(String line, OnLineListener listener) {
if (listener != null) {
if (handler != null) {
final String fLine = line;
final OnLineListener fListener = listener;
startCallback();
handler.post(new Runnable() {
@Override
public void run() {
try {
fListener.onLine(fLine);
} finally {
endCallback();
}
}
});
} else {
listener.onLine(line);
}
}
}
示例2: processLine
import eu.chainfire.libsuperuser.StreamGobbler.OnLineListener; //导入依赖的package包/类
/**
* Process a normal STDOUT/STDERR line
*
* @param line Line to process
* @param listener Callback to call or null
*/
private synchronized void processLine(String line, OnLineListener listener) {
if (listener != null) {
if (handler != null) {
final String fLine = line;
final OnLineListener fListener = listener;
startCallback();
handler.post(new Runnable() {
@Override
public void run() {
try {
fListener.onLine(fLine);
} finally {
endCallback();
}
}
});
} else {
listener.onLine(line);
}
}
}
示例3: processLine
import eu.chainfire.libsuperuser.StreamGobbler.OnLineListener; //导入依赖的package包/类
/**
* Process a normal STDOUT/STDERR line
*
* @param line Line to process
* @param listener Callback to call or null
*/
private synchronized void processLine(String line, OnLineListener listener) {
if (listener != null) {
if (handler != null) {
final String fLine = line;
final OnLineListener fListener = listener;
startCallback();
handler.post(new Runnable() {
@Override
public void run() {
try {
fListener.onLine(fLine);
} finally {
endCallback();
}
}
});
} else {
listener.onLine(line);
}
}
}
示例4: processLine
import eu.chainfire.libsuperuser.StreamGobbler.OnLineListener; //导入依赖的package包/类
/**
* Process a normal STDOUT/STDERR line
*
* @param line Line to process
* @param listener Callback to call or null
*/
private synchronized void processLine(String line, OnLineListener listener) {
if (listener != null) {
if (handler != null) {
final String fLine = line;
final OnLineListener fListener = listener;
startCallback();
handler.post(new Runnable() {
@Override
public void run() {
try {
fListener.onLine(fLine);
} finally {
endCallback();
}
}
});
} else {
listener.onLine(line);
}
}
}
示例5: processLine
import eu.chainfire.libsuperuser.StreamGobbler.OnLineListener; //导入依赖的package包/类
/**
* Process a normal STDOUT/STDERR line
*
* @param line Line to process
* @param listener Callback to call or null
*/
private synchronized void processLine(String line, OnLineListener listener) {
if (listener != null) {
if (handler != null) {
final String fLine = line;
final OnLineListener fListener = listener;
startCallback();
handler.post(new Runnable() {
@Override
public void run() {
try {
fListener.onLine(fLine);
} finally {
endCallback();
}
}
});
} else {
listener.onLine(line);
}
}
}
示例6: open
import eu.chainfire.libsuperuser.StreamGobbler.OnLineListener; //导入依赖的package包/类
/**
* Internal call that launches the shell, starts gobbling, and stars executing commands.
* See {@link Shell.Interactive}
*
* @return Opened successfully ?
*/
private synchronized boolean open() {
if (BuildConfig.DEBUG) Debug.log(String.format("[%s%%] START", shell.toUpperCase()));
try {
// setup our process, retrieve STDIN stream, and STDOUT/STDERR gobblers
if (environment.size() == 0) {
process = Runtime.getRuntime().exec(shell);
} else {
Map<String, String> newEnvironment = new HashMap<String, String>();
newEnvironment.putAll(System.getenv());
newEnvironment.putAll(environment);
int i = 0;
String[] env = new String[newEnvironment.size()];
for (Map.Entry<String, String> entry : newEnvironment.entrySet()) {
env[i] = entry.getKey() + "=" + entry.getValue();
i++;
}
process = Runtime.getRuntime().exec(shell, env);
}
STDIN = new DataOutputStream(process.getOutputStream());
STDOUT = new StreamGobbler(shell.toUpperCase() + "-", process.getInputStream(), new OnLineListener() {
@Override
public void onLine(String line) {
if (line.startsWith(command.marker)) {
try {
lastExitCode = Integer.valueOf(line.substring(command.marker.length() + 1), 10);
} catch (Exception e) {
}
lastMarkerSTDOUT = command.marker;
processMarker();
} else {
addBuffer(line);
processLine(line, onSTDOUTLineListener);
}
}
});
STDERR = new StreamGobbler(shell.toUpperCase() + "*", process.getErrorStream(), new OnLineListener() {
@Override
public void onLine(String line) {
if (line.startsWith(command.marker)) {
lastMarkerSTDERR = command.marker;
processMarker();
} else {
if (wantSTDERR) addBuffer(line);
processLine(line, onSTDERRLineListener);
}
}
});
// start gobbling and write our commands to the shell
STDOUT.start();
STDERR.start();
running = true;
closed = false;
runNextCommand();
return true;
} catch (IOException e) {
// shell probably not found
return false;
}
}
示例7: open
import eu.chainfire.libsuperuser.StreamGobbler.OnLineListener; //导入依赖的package包/类
/**
* Internal call that launches the shell, starts gobbling, and starts executing commands.
* See {@link eu.chainfire.libsuperuser.Shell.Interactive}
*
* @return Opened successfully ?
*/
private synchronized boolean open() {
Debug.log(String.format("[%s%%] START", shell.toUpperCase(Locale.ENGLISH)));
try {
// setup our process, retrieve STDIN stream, and STDOUT/STDERR gobblers
if (environment.size() == 0) {
process = Runtime.getRuntime().exec(shell);
} else {
Map<String, String> newEnvironment = new HashMap<String, String>();
newEnvironment.putAll(System.getenv());
newEnvironment.putAll(environment);
int i = 0;
String[] env = new String[newEnvironment.size()];
for (Map.Entry<String, String> entry : newEnvironment.entrySet()) {
env[i] = entry.getKey() + "=" + entry.getValue();
i++;
}
process = Runtime.getRuntime().exec(shell, env);
}
STDIN = new DataOutputStream(process.getOutputStream());
STDOUT = new StreamGobbler(shell.toUpperCase(Locale.ENGLISH) + "-", process.getInputStream(), new OnLineListener() {
@Override
public void onLine(String line) {
synchronized (Interactive.this) {
if (command == null) {
return;
}
if (line.startsWith(command.marker)) {
try {
lastExitCode = Integer.valueOf(line.substring(command.marker.length() + 1), 10);
} catch (Exception e) {
}
lastMarkerSTDOUT = command.marker;
processMarker();
} else {
addBuffer(line);
processLine(line, onSTDOUTLineListener);
}
}
}
});
STDERR = new StreamGobbler(shell.toUpperCase(Locale.ENGLISH) + "*", process.getErrorStream(), new OnLineListener() {
@Override
public void onLine(String line) {
synchronized (Interactive.this) {
if (command == null) {
return;
}
if (line.startsWith(command.marker)) {
lastMarkerSTDERR = command.marker;
processMarker();
} else {
if (wantSTDERR) addBuffer(line);
processLine(line, onSTDERRLineListener);
}
}
}
});
// start gobbling and write our commands to the shell
STDOUT.start();
STDERR.start();
running = true;
closed = false;
runNextCommand();
return true;
} catch (IOException e) {
// shell probably not found
return false;
}
}
示例8: open
import eu.chainfire.libsuperuser.StreamGobbler.OnLineListener; //导入依赖的package包/类
/**
* Internal call that launches the shell, starts gobbling, and starts executing commands.
* See {@link Shell.Interactive}
*
* @return Opened successfully ?
*/
private synchronized boolean open() {
Debug.log(String.format("[%s%%] START", shell.toUpperCase(Locale.ENGLISH)));
try {
// setup our process, retrieve STDIN stream, and STDOUT/STDERR gobblers
if (environment.size() == 0) {
process = Runtime.getRuntime().exec(shell);
} else {
Map<String, String> newEnvironment = new HashMap<String, String>();
newEnvironment.putAll(System.getenv());
newEnvironment.putAll(environment);
int i = 0;
String[] env = new String[newEnvironment.size()];
for (Map.Entry<String, String> entry : newEnvironment.entrySet()) {
env[i] = entry.getKey() + "=" + entry.getValue();
i++;
}
process = Runtime.getRuntime().exec(shell, env);
}
STDIN = new DataOutputStream(process.getOutputStream());
STDOUT = new StreamGobbler(shell.toUpperCase(Locale.ENGLISH) + "-", process.getInputStream(), new OnLineListener() {
@Override
public void onLine(String line) {
synchronized (Interactive.this) {
if (command == null) {
return;
}
if (line.startsWith(command.marker)) {
try {
lastExitCode = Integer.valueOf(line.substring(command.marker.length() + 1), 10);
} catch (Exception e) {
}
lastMarkerSTDOUT = command.marker;
processMarker();
} else {
addBuffer(line);
processLine(line, onSTDOUTLineListener);
}
}
}
});
STDERR = new StreamGobbler(shell.toUpperCase(Locale.ENGLISH) + "*", process.getErrorStream(), new OnLineListener() {
@Override
public void onLine(String line) {
synchronized (Interactive.this) {
if (command == null) {
return;
}
if (line.startsWith(command.marker)) {
lastMarkerSTDERR = command.marker;
processMarker();
} else {
if (wantSTDERR) addBuffer(line);
processLine(line, onSTDERRLineListener);
}
}
}
});
// start gobbling and write our commands to the shell
STDOUT.start();
STDERR.start();
running = true;
closed = false;
runNextCommand();
return true;
} catch (IOException e) {
// shell probably not found
return false;
}
}
示例9: open
import eu.chainfire.libsuperuser.StreamGobbler.OnLineListener; //导入依赖的package包/类
/**
* Internal call that launches the shell, starts gobbling, and starts executing commands.
* See {@link Shell.Interactive}
*
* @return Opened successfully ?
*/
private synchronized boolean open() {
Debug.log(String.format("[%s%%] START", shell.toUpperCase(Locale.ENGLISH)));
try {
// setup our process, retrieve STDIN stream, and STDOUT/STDERR gobblers
if (environment.size() == 0) {
process = Runtime.getRuntime().exec(shell);
} else {
Map<String, String> newEnvironment = new HashMap<String, String>();
newEnvironment.putAll(System.getenv());
newEnvironment.putAll(environment);
int i = 0;
String[] env = new String[newEnvironment.size()];
for (Map.Entry<String, String> entry : newEnvironment.entrySet()) {
env[i] = entry.getKey() + "=" + entry.getValue();
i++;
}
process = Runtime.getRuntime().exec(shell, env);
}
STDIN = new DataOutputStream(process.getOutputStream());
STDOUT = new StreamGobbler(shell.toUpperCase(Locale.ENGLISH) + "-", process.getInputStream(), new OnLineListener() {
@Override
public void onLine(String line) {
synchronized (Interactive.this) {
if (command == null) {
return;
}
if (line.startsWith(command.marker)) {
try {
lastExitCode = Integer.valueOf(line.substring(command.marker.length() + 1), 10);
} catch (Exception e) {
}
lastMarkerSTDOUT = command.marker;
processMarker();
} else {
addBuffer(line);
processLine(line, onSTDOUTLineListener);
}
}
}
});
STDERR = new StreamGobbler(shell.toUpperCase(Locale.ENGLISH) + "*", process.getErrorStream(), new OnLineListener() {
@Override
public void onLine(String line) {
synchronized (Interactive.this) {
if (command == null) {
return;
}
if (line.startsWith(command.marker)) {
lastMarkerSTDERR = command.marker;
processMarker();
} else {
if (wantSTDERR) addBuffer(line);
processLine(line, onSTDERRLineListener);
}
}
}
});
// start gobbling and write our commands to the shell
STDOUT.start();
STDERR.start();
running = true;
closed = false;
runNextCommand();
return true;
} catch (IOException e) {
// shell probably not found
return false;
}
}
示例10: open
import eu.chainfire.libsuperuser.StreamGobbler.OnLineListener; //导入依赖的package包/类
/**
* Internal call that launches the shell, starts gobbling, and starts executing commands.
* See {@link Shell.Interactive}
*
* @return Opened successfully ?
*/
private synchronized boolean open() {
Debug.log(String.format("[%s%%] START", shell.toUpperCase(Locale.ENGLISH)));
try {
// setup our process, retrieve STDIN stream, and STDOUT/STDERR gobblers
if (environment.size() == 0) {
process = Runtime.getRuntime().exec(shell);
} else {
Map<String, String> newEnvironment = new HashMap<String, String>();
newEnvironment.putAll(System.getenv());
newEnvironment.putAll(environment);
int i = 0;
String[] env = new String[newEnvironment.size()];
for (Map.Entry<String, String> entry : newEnvironment.entrySet()) {
env[i] = entry.getKey() + "=" + entry.getValue();
i++;
}
process = Runtime.getRuntime().exec(shell, env);
}
STDIN = new DataOutputStream(process.getOutputStream());
STDOUT = new StreamGobbler(shell.toUpperCase(Locale.ENGLISH) + "-", process.getInputStream(), new OnLineListener() {
@Override
public void onLine(String line) {
synchronized (Interactive.this) {
if (command == null) {
return;
}
if (line.startsWith(command.marker)) {
try {
lastExitCode = Integer.valueOf(line.substring(command.marker.length() + 1), 10);
} catch (Exception e) {
}
lastMarkerSTDOUT = command.marker;
processMarker();
} else {
addBuffer(line);
processLine(line, onSTDOUTLineListener);
}
}
}
});
STDERR = new StreamGobbler(shell.toUpperCase(Locale.ENGLISH) + "*", process.getErrorStream(), new OnLineListener() {
@Override
public void onLine(String line) {
synchronized (Interactive.this) {
if (command == null) {
return;
}
if (line.startsWith(command.marker)) {
lastMarkerSTDERR = command.marker;
processMarker();
} else {
if (wantSTDERR) addBuffer(line);
processLine(line, onSTDERRLineListener);
}
}
}
});
// start gobbling and write our commands to the shell
STDOUT.start();
STDERR.start();
running = true;
closed = false;
runNextCommand();
return true;
} catch (IOException e) {
// shell probably not found
return false;
}
}
示例11: open
import eu.chainfire.libsuperuser.StreamGobbler.OnLineListener; //导入依赖的package包/类
/**
* Internal call that launches the shell, starts gobbling, and stars executing commands.
* See {@link Shell.Interactive}
*
* @return Opened successfully ?
*/
private synchronized boolean open() {
//if (BuildConfig.DEBUG) Debug.log(String.format("[%s%%] START", shell.toUpperCase()));
try {
// setup our process, retrieve STDIN stream, and STDOUT/STDERR gobblers
if (environment.size() == 0) {
process = Runtime.getRuntime().exec(shell);
} else {
Map<String, String> newEnvironment = new HashMap<String, String>();
newEnvironment.putAll(System.getenv());
newEnvironment.putAll(environment);
int i = 0;
String[] env = new String[newEnvironment.size()];
for (Map.Entry<String, String> entry : newEnvironment.entrySet()) {
env[i] = entry.getKey() + "=" + entry.getValue();
i++;
}
process = Runtime.getRuntime().exec(shell, env);
}
STDIN = new DataOutputStream(process.getOutputStream());
STDOUT = new StreamGobbler(shell.toUpperCase() + "-", process.getInputStream(), new OnLineListener() {
@Override
public void onLine(String line) {
if (line.startsWith(command.marker)) {
try {
lastExitCode = Integer.valueOf(line.substring(command.marker.length() + 1), 10);
} catch (Exception e) {
}
lastMarkerSTDOUT = command.marker;
processMarker();
} else {
addBuffer(line);
processLine(line, onSTDOUTLineListener);
}
}
});
STDERR = new StreamGobbler(shell.toUpperCase() + "*", process.getErrorStream(), new OnLineListener() {
@Override
public void onLine(String line) {
if (line.startsWith(command.marker)) {
lastMarkerSTDERR = command.marker;
processMarker();
} else {
if (wantSTDERR) addBuffer(line);
processLine(line, onSTDERRLineListener);
}
}
});
// start gobbling and write our commands to the shell
STDOUT.start();
STDERR.start();
running = true;
closed = false;
runNextCommand();
return true;
} catch (IOException e) {
// shell probably not found
return false;
}
}
示例12: setOnSTDOUTLineListener
import eu.chainfire.libsuperuser.StreamGobbler.OnLineListener; //导入依赖的package包/类
/**
* <p>
* Set a callback called for every line output to STDOUT by the shell
* </p>
* <p>
* The thread on which the callback executes is dependent on various
* factors, see {@link Shell.Interactive} for further details
* </p>
*
* @param onLineListener Callback to be called for each line
* @return This Builder object for method chaining
*/
public Builder setOnSTDOUTLineListener(OnLineListener onLineListener) {
this.onSTDOUTLineListener = onLineListener;
return this;
}
示例13: setOnSTDERRLineListener
import eu.chainfire.libsuperuser.StreamGobbler.OnLineListener; //导入依赖的package包/类
/**
* <p>
* Set a callback called for every line output to STDERR by the shell
* </p>
* <p>
* The thread on which the callback executes is dependent on various
* factors, see {@link Shell.Interactive} for further details
* </p>
*
* @param onLineListener Callback to be called for each line
* @return This Builder object for method chaining
*/
public Builder setOnSTDERRLineListener(OnLineListener onLineListener) {
this.onSTDERRLineListener = onLineListener;
return this;
}
示例14: setOnSTDOUTLineListener
import eu.chainfire.libsuperuser.StreamGobbler.OnLineListener; //导入依赖的package包/类
/**
* <p>
* Set a callback called for every line output to STDOUT by the shell
* </p>
* <p>
* The thread on which the callback executes is dependent on various
* factors, see {@link Shell.Interactive} for further details
* </p>
*
* @param onLineListener Callback to be called for each line
* @return This Builder object for method chaining
*/
public Builder setOnSTDOUTLineListener(OnLineListener onLineListener) {
this.onSTDOUTLineListener = onLineListener;
return this;
}
示例15: setOnSTDERRLineListener
import eu.chainfire.libsuperuser.StreamGobbler.OnLineListener; //导入依赖的package包/类
/**
* <p>
* Set a callback called for every line output to STDERR by the shell
* </p>
* <p>
* The thread on which the callback executes is dependent on various
* factors, see {@link Shell.Interactive} for further details
* </p>
*
* @param onLineListener Callback to be called for each line
* @return This Builder object for method chaining
*/
public Builder setOnSTDERRLineListener(OnLineListener onLineListener) {
this.onSTDERRLineListener = onLineListener;
return this;
}