List of usage examples for org.apache.commons.io LineIterator nextLine
public String nextLine()
Reader
. From source file:com.rodaxsoft.mailgun.message.tools.MailgunSender.java
/** * Sends message to the recipients specified by the <code>-R</code> option. * @param cmd Command line arguments//from w w w. j av a2 s. c o m * @param text Plain text email content * @param html HTML email content * @throws ContextedRuntimeException if the recipients option or -R is omitted. */ private static void sendMessageToRecipientsInFile(CommandLine cmd, String text, String html) { if (cmd.hasOption(RECIPIENTS_FILE_OPT)) { LineIterator it = null; try { it = FileUtils.lineIterator(new File(cmd.getOptionValue(RECIPIENTS_FILE_OPT)), "UTF-8"); while (it.hasNext()) { final String to = it.nextLine(); //Build the email request object final EmailRequest er = makeEmailRequest(cmd, text, html, to); LOG.trace(er); sendMessage(cmd, er); } } catch (IOException e) { LOG.error("Error occurre while sending from recipients file", e); } finally { LineIterator.closeQuietly(it); } } else { final String msg = "Option must be a recipients file"; handleOmittedOptionError(cmd, msg); } }
From source file:data_gen.Data_gen.java
private static void switch_file(List<String> tx) throws IOException { if (listOfFiles.length == 1) { file_index = 0;// ww w . j a va 2s . co m LineIterator it = FileUtils.lineIterator(listOfFiles[file_index]); while (it.hasNext()) { tx.add(it.nextLine()); } } if (listOfFiles.length > 1) { ++file_index; LineIterator it = FileUtils.lineIterator(listOfFiles[file_index]); while (it.hasNext()) { tx.add(it.nextLine()); } if (file_index == listOfFiles.length - 1) { file_index = 0; } } }
From source file:com.nts.alphamale.handler.DeviceHandler.java
public static String installApp(String serial, String apkPath, int timeoutSecond) { String rtnValue = ""; Map<String, Object> executorMap = new AdbShellExecutor().execute( AdbShellCommand.cmd(serial, "cmd_install_app", new String[] { apkPath }), false, Settings.EXECUTOR_TIMEOUT); if (executorMap.isEmpty()) { return rtnValue; }//from w w w . ja v a 2s . co m LineIterator li = Utils.getLineIterator(executorMap.get("stdOut")); while (li != null && li.hasNext()) { rtnValue += li.nextLine().trim(); } Utils.destoryExecutor(executorMap.get("executor")); return rtnValue; }
From source file:com.nts.alphamale.handler.DeviceHandler.java
public static String unInstallApp(String serial, String packageName, int timeoutSecond) { String rtnValue = ""; Map<String, Object> executorMap = new AdbShellExecutor().execute( AdbShellCommand.cmd(serial, "cmd_uninstall_app", new String[] { packageName }), false, Settings.EXECUTOR_TIMEOUT); if (executorMap.isEmpty()) { return rtnValue; }//from ww w.j a v a 2 s. c o m LineIterator li = Utils.getLineIterator(executorMap.get("stdOut")); while (li != null && li.hasNext()) { rtnValue += li.nextLine().trim(); } Utils.destoryExecutor(executorMap.get("executor")); return rtnValue; }
From source file:com.nts.alphamale.handler.DeviceHandler.java
public static List<String> get3rdPartyPackageList(String serial) { List<String> pkgList = new ArrayList<String>(); Map<String, Object> executorMap = new AdbShellExecutor().execute( AdbShellCommand.cmd(serial, "cmd_3rd_party_package_list"), false, Settings.EXECUTOR_TIMEOUT); if (executorMap.isEmpty()) { return pkgList; }/*from www . j a va 2 s .c om*/ LineIterator li = Utils.getLineIterator(executorMap.get("stdOut")); while (li != null && li.hasNext()) { String str = li.nextLine().trim(); if (str.contains("package:")) { pkgList.add(str.replace("package:", "")); } } Utils.destoryExecutor(executorMap.get("executor")); return pkgList; }
From source file:com.nts.alphamale.handler.DeviceHandler.java
/** * getInputManager? SurfaceOrientation? ?? * {@link #getInputManager(String)}/*from w ww . jav a2 s . c om*/ * * @param serial * @return */ public static int getOrientation(String serial) { int rtnValue = 0; Map<String, Object> executorMap = new AdbShellExecutor() .execute(AdbShellCommand.cmd(serial, "cmd_get_orientation"), false, Settings.EXECUTOR_TIMEOUT); if (executorMap.isEmpty()) { return rtnValue; } LineIterator li = Utils.getLineIterator(executorMap.get("stdOut")); while (li != null && li.hasNext()) { String out = li.nextLine().trim(); if (out.contains("SurfaceOrientation:")) { rtnValue = Integer.parseInt(Utils.convertRegex("(\\d)", out, 1)); } } Utils.destoryExecutor(executorMap.get("executor")); return rtnValue; }
From source file:com.nts.alphamale.handler.DeviceHandler.java
public static Map<String, String> getProp(String serial) { Map<String, String> rtnValue = new HashMap<String, String>(); Map<String, Object> executorMap = new AdbShellExecutor().execute(AdbShellCommand.cmd(serial, "cmd_getprop"), false, Settings.EXECUTOR_TIMEOUT); if (executorMap.isEmpty()) { return null; }/*ww w . ja v a 2s .co m*/ LineIterator li = Utils.getLineIterator(executorMap.get("stdOut")); while (li != null && li.hasNext()) { String out = li.nextLine().trim(); if (!out.isEmpty() && !out.startsWith("[]")) { out = out.replace("]: [", ":").replace("[", "").replace("]", ""); if (out.split(":").length == 2) rtnValue.put(out.split(":")[0], out.split(":")[1]); } } Utils.destoryExecutor(executorMap.get("executor")); return rtnValue; }
From source file:com.nts.alphamale.handler.DeviceHandler.java
public static boolean isKeyPadAppear(String serial) { Map<String, Object> executorMap = new AdbShellExecutor() .execute(AdbShellCommand.cmd(serial, "cmd_keypad_monitor"), false, Settings.EXECUTOR_TIMEOUT); if (executorMap.isEmpty()) { return false; }/*w ww .ja v a 2 s. c o m*/ LineIterator li = Utils.getLineIterator(executorMap.get("stdOut")); if (li != null && li.hasNext()) { String str = li.nextLine().trim(); if (str.contains("HasSurface=true")) { DataQueue.IS_KEYPAD_ON = true; } else { DataQueue.IS_KEYPAD_ON = false; } } Utils.destoryExecutor(executorMap.get("executor")); return DataQueue.IS_KEYPAD_ON; }
From source file:com.nts.alphamale.handler.DeviceHandler.java
/** * adb devices ? ?? ? ?? ? ?/*from w w w . j a v a2s. com*/ * * @return */ public static boolean isAdbReady(String serial) { boolean rtnValue = false; Map<String, Object> executorMap = new AdbShellExecutor().execute(AdbShellCommand.cmd("", "cmd_devices"), true, Settings.EXECUTOR_TIMEOUT); if (executorMap.isEmpty()) { return rtnValue; } LineIterator li = Utils.getLineIterator(executorMap.get("stdOut")); while (li != null && li.hasNext()) { String device = li.nextLine(); if (!device.contains("List of devices attached") && device.contains(serial)) { rtnValue = true; } } Utils.destoryExecutor(executorMap.get("executor")); return rtnValue; }
From source file:com.nts.alphamale.handler.DeviceHandler.java
public static List<String> getDeviceList() { List<String> deviceList = new ArrayList<String>(); Map<String, Object> executorMap = new AdbShellExecutor().execute(AdbShellCommand.cmd("", "cmd_devices"), true, Settings.EXECUTOR_TIMEOUT); if (executorMap.isEmpty()) { return deviceList; }/*from w ww . j a v a 2s. c o m*/ LineIterator li = Utils.getLineIterator(executorMap.get("stdOut")); while (li != null && li.hasNext()) { String device = li.nextLine(); if (device.contains("device")) { if (!device.contains("List of devices attached")) deviceList.add(device.replace("device", "").trim()); } } Utils.destoryExecutor(executorMap.get("executor")); return deviceList; }