List of usage examples for org.apache.commons.io IOUtils readLines
public static List readLines(Reader input) throws IOException
Reader
as a list of Strings, one entry per line. From source file:com.sunsprinter.diffunit.core.comparison.AbstractFileComparer.java
@Override public void compareAllFiles() throws Exception { // Get the input location type from the annotation on the class. If we don't have one we default to CLASSPATH. final DiffUnitInputLocation classInputLocationAnnotation = getTestingContext().getTestClass() .getAnnotation(DiffUnitInputLocation.class); final InputLocationType locationType = classInputLocationAnnotation == null ? InputLocationType.CLASSPATH : classInputLocationAnnotation.locationType(); final String classInputLocation = classInputLocationAnnotation == null ? null : classInputLocationAnnotation.location(); // Figure out the input location path by checking to see what our location type is. final String inputLocation; if (locationType == InputLocationType.CLASSPATH) { inputLocation = classInputLocation == null ? String.format("/%s/%s", getTestingContext().getTestClass().getSimpleName(), getTestingContext().getTestName()) : classInputLocation;//w w w.jav a 2 s . c o m } else { inputLocation = classInputLocation == null ? String.format("src/test/resources/%s/%s", getTestingContext().getTestClass().getSimpleName(), getTestingContext().getTestName()) : classInputLocation; } // Go through all the files we wrote and compare them against the known good ones stored in the input location. for (final File generatedFile : getFilesToCompare()) { final String knownGoodTextFileName = generatedFile.getName(); InputStream knownGoodInputStream = null; InputStream generatedInputStream = null; try { final String inputStreamLocation = inputLocation + "/" + knownGoodTextFileName; if (locationType == InputLocationType.CLASSPATH) { knownGoodInputStream = getClass().getResourceAsStream(inputStreamLocation); } else { try { knownGoodInputStream = new FileInputStream(inputStreamLocation); } catch (final FileNotFoundException e) { // Do nothing here. We handle not being able to find the input file below. } } if (knownGoodInputStream == null) { // There's no input file. We create a dummy one for comparison purposes. This lets the // developer see differences for all files rather than just bailing here. knownGoodInputStream = new ByteArrayInputStream( String.format("Input file %s not found.", inputStreamLocation).getBytes()); } final Collection<String> knownGoodLines = IOUtils.readLines(knownGoodInputStream); generatedInputStream = new FileInputStream(generatedFile); final Collection<String> generatedLines = IOUtils.readLines(generatedInputStream); assertEqual(knownGoodLines, inputStreamLocation, locationType, generatedLines, generatedFile); } finally { IOUtils.closeQuietly(knownGoodInputStream); IOUtils.closeQuietly(generatedInputStream); } } }
From source file:android.databinding.tool.DataBindingBuilder.java
private List<String> readGeneratedClasses(File generatedClassListFile) { Preconditions.checkNotNull(generatedClassListFile, "Data binding exclude generated task" + " is not configured properly"); Preconditions.check(generatedClassListFile.exists(), "Generated class list does not exist %s", generatedClassListFile.getAbsolutePath()); FileInputStream fis = null;//from w w w . j a va 2 s .c o m try { fis = new FileInputStream(generatedClassListFile); return IOUtils.readLines(fis); } catch (FileNotFoundException e) { L.e(e, "Unable to read generated class list from %s", generatedClassListFile.getAbsoluteFile()); } catch (IOException e) { L.e(e, "Unexpected exception while reading %s", generatedClassListFile.getAbsoluteFile()); } finally { IOUtils.closeQuietly(fis); } L.e("Could not read data binding generated class list"); return null; }
From source file:com.doculibre.constellio.services.ACLServicesImpl.java
@Override public List<PolicyACLEntry> parse(InputStream aclInputStream, RecordCollection collection) { List<PolicyACLEntry> entries = new ArrayList<PolicyACLEntry>(); List<String> aclLines; try {/*from ww w. j a v a 2 s.c o m*/ aclLines = IOUtils.readLines(aclInputStream); IOUtils.closeQuietly(aclInputStream); } catch (IOException e) { throw new RuntimeException(e); } for (String aclLine : aclLines) { try { String fieldName = null; String regexp = null; Set<String> userNames = new HashSet<String>(); Set<String> groupNames = new HashSet<String>(); StringTokenizer aclTokens = new StringTokenizer(aclLine, " "); while (aclTokens.hasMoreTokens()) { String aclToken = aclTokens.nextToken(); int indexOfColon = aclToken.indexOf(":"); if (indexOfColon != -1) { String fieldOrGroupOrUserName = aclToken.substring(0, indexOfColon); String fieldOrGroupOrUserValue = aclToken.substring(indexOfColon + 1); if (StringUtils.isNotBlank(fieldOrGroupOrUserValue)) { if ("group".equalsIgnoreCase(fieldOrGroupOrUserName)) { groupNames.add(fieldOrGroupOrUserValue); } else if ("user".equalsIgnoreCase(fieldOrGroupOrUserName)) { userNames.add(fieldOrGroupOrUserValue); } else { fieldName = fieldOrGroupOrUserName; regexp = fieldOrGroupOrUserValue; } } else { // Skip token LOGGER.log(Level.SEVERE, "Invalid ACL token skipped : " + aclToken); continue; } } else { fieldName = IndexField.URL_FIELD; regexp = aclToken; } } if (fieldName != null && regexp != null && (!userNames.isEmpty() || !groupNames.isEmpty())) { IndexField indexField = collection.getIndexField(fieldName); if (indexField == null) { // A URL will probably start with http: or https: which will have been misinterpreted // as a field name indexField = collection.getIndexField(IndexField.URL_FIELD); regexp = fieldName + ":" + regexp; } Set<ConstellioUser> users = new HashSet<ConstellioUser>(); Set<ConstellioGroup> groups = new HashSet<ConstellioGroup>(); UserServices userServices = ConstellioSpringUtils.getUserServices(); GroupServices groupServices = ConstellioSpringUtils.getGroupServices(); for (String userName : userNames) { ConstellioUser user = userServices.get(userName); if (user != null) { users.add(user); } else { // Skip line LOGGER.log(Level.SEVERE, "Invalid username skipped : " + userName); } } for (String groupName : groupNames) { ConstellioGroup group = groupServices.get(groupName); if (group != null) { groups.add(group); } else { // Skip line LOGGER.log(Level.SEVERE, "Invalid group name skipped : " + groupName); } } if (!users.isEmpty() || !groups.isEmpty()) { PolicyACLEntry entry = new PolicyACLEntry(); entry.setIndexField(indexField); entry.setMatchRegexp(regexp); entry.setGroups(groups); entry.setUsers(users); entries.add(entry); } else { // Skip line LOGGER.log(Level.SEVERE, "Invalid ACL line skipped : " + aclLine); } } else { // Skip line LOGGER.log(Level.SEVERE, "Invalid ACL line skipped : " + aclLine); } } catch (Exception e) { // Skip line LOGGER.log(Level.SEVERE, "Exception while parsing line of ACL input stream", e); } } return entries; }
From source file:dpcs.UninstallUserApps.java
@SuppressWarnings({ "unchecked", "rawtypes", "deprecation" }) public UninstallUserApps() { setResizable(false);//from w ww .j a v a2 s .co m setTitle("Uninstall User Apps"); setIconImage( Toolkit.getDefaultToolkit().getImage(UninstallSystemApps.class.getResource("/graphics/Icon.png"))); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setBounds(100, 100, 482, 430); contentPane = new JPanel(); contentPane.setBackground(Color.WHITE); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(null); JLabel AppStatus = new JLabel(""); AppStatus.setBounds(12, 366, 456, 17); contentPane.add(AppStatus); UserAppUninstallDone = new JLabel(""); UserAppUninstallDone.setText(""); UserAppUninstallDone.setBounds(151, 312, 186, 56); contentPane.add(UserAppUninstallDone); JLabel lblSelect = new JLabel("Select an app to remove"); lblSelect.setBounds(26, 12, 405, 17); contentPane.add(lblSelect); JScrollPane scrollPane = new JScrollPane(); scrollPane.setBounds(22, 41, 428, 259); contentPane.add(scrollPane); final JButton btnUninstall = new JButton("Uninstall"); btnUninstall.setToolTipText("Uninstall the selected app"); btnUninstall.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { UserAppUninstallDone.setText(""); if (list.getSelectedValue() == null) { JOptionPane.showMessageDialog(null, "Please select an app first"); } else { try { AppStatus.setText("Uninstalling..."); String[] commands = new String[3]; commands[0] = "adb"; commands[1] = "uninstall"; commands[2] = "" + list.getSelectedValue(); Process p1 = Runtime.getRuntime().exec(commands, null); p1.waitFor(); Process p2 = Runtime.getRuntime() .exec("adb shell pm list packages -3 > /sdcard/.userapps.txt"); p2.waitFor(); Process p3 = Runtime.getRuntime().exec("adb pull /sdcard/.userapps.txt"); p3.waitFor(); Process p4 = Runtime.getRuntime().exec("adb shell rm /sdcard/.userapps.txt"); p4.waitFor(); lines = IOUtils.readLines(new FileInputStream(".userapps.txt")); values = new String[lines.size()]; values = lines.toArray(values); moddedvalues = new String[values.length]; for (int i = 0; i < values.length; i++) { moddedvalues[i] = values[i].substring(8); } list = new JList(); list.setModel(new AbstractListModel() { public int getSize() { return moddedvalues.length; } public Object getElementAt(int index) { return moddedvalues[index]; } }); scrollPane.setViewportView(list); File file = new File(".userapps.txt"); if (file.exists() && !file.isDirectory()) { file.delete(); } AppStatus.setText("App has been uninstalled successfully"); UserAppUninstallDone .setIcon(new ImageIcon(Interface.class.getResource("/graphics/Smalldone.png"))); btnUninstall.setSelected(false); } catch (Exception e1) { System.err.println(e1); } } } }); btnUninstall.setBounds(26, 327, 107, 27); contentPane.add(btnUninstall); JButton btnRefresh = new JButton("Refresh"); btnRefresh.setToolTipText("Refresh the apps list"); btnRefresh.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { Process p1 = Runtime.getRuntime().exec("adb shell pm list packages -3 > /sdcard/.userapps.txt"); p1.waitFor(); Process p2 = Runtime.getRuntime().exec("adb pull /sdcard/.userapps.txt"); p2.waitFor(); Process p3 = Runtime.getRuntime().exec("adb shell rm /sdcard/.userapps.txt"); p3.waitFor(); lines = IOUtils.readLines(new FileInputStream(".userapps.txt")); values = new String[lines.size()]; values = lines.toArray(values); moddedvalues = new String[values.length]; for (int i = 0; i < values.length; i++) { moddedvalues[i] = values[i].substring(8); } list = new JList(); list.setModel(new AbstractListModel() { public int getSize() { return moddedvalues.length; } public Object getElementAt(int index) { return moddedvalues[index]; } }); scrollPane.setViewportView(list); File file = new File(".userapps.txt"); if (file.exists() && !file.isDirectory()) { file.delete(); } } catch (Exception e1) { System.err.println(e1); } } }); btnRefresh.setBounds(344, 327, 107, 27); contentPane.add(btnRefresh); try { Process p1 = Runtime.getRuntime().exec("adb shell pm list packages -3 > /sdcard/.userapps.txt"); p1.waitFor(); Process p2 = Runtime.getRuntime().exec("adb pull /sdcard/.userapps.txt"); p2.waitFor(); Process p3 = Runtime.getRuntime().exec("adb shell rm /sdcard/.userapps.txt"); p3.waitFor(); lines = IOUtils.readLines(new FileInputStream(".userapps.txt")); values = new String[lines.size()]; values = lines.toArray(values); moddedvalues = new String[values.length]; for (int i = 0; i < values.length; i++) { moddedvalues[i] = values[i].substring(8); } list = new JList(); list.setModel(new AbstractListModel() { public int getSize() { return moddedvalues.length; } public Object getElementAt(int index) { return moddedvalues[index]; } }); scrollPane.setViewportView(list); File file = new File(".userapps.txt"); if (file.exists() && !file.isDirectory()) { file.delete(); } } catch (Exception e1) { System.err.println(e1); } }
From source file:com.talis.platform.sequencing.zookeeper.ZooKeeperProvider.java
private String readEnsembleList() throws IOException { InputStream ensembleListStream = this.getClass().getResourceAsStream(DEFAULT_SERVER_LIST_LOCATION); String theFilename = System.getProperty(SERVER_LIST_LOCATION_PROPERTY); if (null == theFilename) { if (LOG.isInfoEnabled()) { LOG.info("No server list specified in system " + "property using default"); }/* w w w . j av a 2 s . co m*/ } else { if (LOG.isInfoEnabled()) { LOG.info(String.format("Initialising server list from file %s", theFilename)); } ensembleListStream = FileUtils.openInputStream(new File(theFilename)); } String list = ((String) IOUtils.readLines(ensembleListStream).get(0)).trim(); if (LOG.isInfoEnabled()) { LOG.info(String.format("Read ensemble list => %s", list)); } return list; }
From source file:com.streamsets.pipeline.stage.destination.s3.TestAmazonS3Target.java
@Test public void testWriteTextData() throws Exception { String prefix = "textPrefix"; AmazonS3Target amazonS3Target = createS3targetWithTextData(prefix, false); TargetRunner targetRunner = new TargetRunner.Builder(AmazonS3DTarget.class, amazonS3Target).build(); targetRunner.runInit();//from w ww .j av a2 s . com List<Record> logRecords = TestUtil.createStringRecords(); //Make sure the prefix is empty ObjectListing objectListing = s3client.listObjects(BUCKET_NAME, prefix); Assert.assertTrue(objectListing.getObjectSummaries().isEmpty()); targetRunner.runWrite(logRecords); targetRunner.runDestroy(); //check that prefix contains 1 file objectListing = s3client.listObjects(BUCKET_NAME, prefix); Assert.assertEquals(1, objectListing.getObjectSummaries().size()); S3ObjectSummary objectSummary = objectListing.getObjectSummaries().get(0); //get contents of file and check data - should have 9 lines S3Object object = s3client.getObject(BUCKET_NAME, objectSummary.getKey()); S3ObjectInputStream objectContent = object.getObjectContent(); List<String> stringList = IOUtils.readLines(objectContent); Assert.assertEquals(9, stringList.size()); for (int i = 0; i < 9; i++) { Assert.assertEquals(TestUtil.TEST_STRING + i, stringList.get(i)); } }
From source file:bixo.examples.webmining.DemoWebMiningWorkflow.java
@SuppressWarnings({ "unchecked", "rawtypes" }) public static void importSeedUrls(BasePlatform platform, BasePath crawlDbPath, String fileName) throws Exception { SimpleUrlNormalizer normalizer = new SimpleUrlNormalizer(); InputStream is = null;/*from w w w.j ava 2 s.c o m*/ TupleEntryCollector writer = null; try { Tap urlSink = platform.makeTap(platform.makeTextScheme(), crawlDbPath, SinkMode.REPLACE); writer = urlSink.openForWrite(platform.makeFlowProcess()); is = DemoWebMiningWorkflow.class.getResourceAsStream(fileName); if (is == null) { throw new FileNotFoundException("The seed urls file doesn't exist"); } List<String> lines = IOUtils.readLines(is); for (String line : lines) { line = line.trim(); if (line.startsWith("#")) { continue; } CrawlDbDatum datum = new CrawlDbDatum(normalizer.normalize(line), 0, UrlStatus.UNFETCHED, 0.0f, 0.0f); writer.add(datum.getTuple()); } } catch (IOException e) { crawlDbPath.delete(true); throw e; } finally { IoUtils.safeClose(is); if (writer != null) { writer.close(); } } }
From source file:dpcs.UninstallSystemApps.java
@SuppressWarnings({ "unchecked", "rawtypes", "deprecation" }) public UninstallSystemApps() { setResizable(false);// ww w. j a v a 2s . c o m setTitle("Uninstall System Apps"); setIconImage( Toolkit.getDefaultToolkit().getImage(UninstallSystemApps.class.getResource("/graphics/Icon.png"))); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setBounds(100, 100, 482, 475); contentPane = new JPanel(); contentPane.setBackground(Color.WHITE); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(null); JLabel AppStatus = new JLabel(""); AppStatus.setBounds(12, 393, 456, 17); contentPane.add(AppStatus); SystemAppUninstallDone = new JLabel(""); SystemAppUninstallDone.setBounds(151, 312, 186, 56); contentPane.add(SystemAppUninstallDone); JLabel lblSelect = new JLabel("Select an app to remove"); lblSelect.setBounds(26, 12, 405, 17); contentPane.add(lblSelect); JScrollPane scrollPane = new JScrollPane(); scrollPane.setBounds(22, 41, 428, 259); contentPane.add(scrollPane); final JButton btnUninstall = new JButton("Uninstall"); btnUninstall.setToolTipText("Uninstall the selected app"); btnUninstall.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SystemAppUninstallDone.setText(""); if (list.getSelectedValue() == null) { JOptionPane.showMessageDialog(null, "Please select an app first"); } else { try { AppStatus.setText("Uninstalling..."); Process p1 = Runtime.getRuntime().exec("adb remount"); p1.waitFor(); String[] commands = new String[3]; commands[0] = "adb shell su -c rm -r "; commands[1] = "/system/app/"; commands[2] = " " + list.getSelectedValue(); Process p2 = Runtime.getRuntime().exec(commands, null); p2.waitFor(); Process p3 = Runtime.getRuntime() .exec("adb shell ls /system/app/ > /sdcard/.systemapps.txt"); p3.waitFor(); Process p4 = Runtime.getRuntime().exec("adb pull /sdcard/.systemapps.txt"); p4.waitFor(); Process p5 = Runtime.getRuntime().exec("adb shell rm /sdcard/.systemapps.txt"); p5.waitFor(); lines = IOUtils.readLines(new FileInputStream(".systemapps.txt")); values = new String[lines.size()]; values = lines.toArray(values); list = new JList(); list.setModel(new AbstractListModel() { public int getSize() { return values.length; } public Object getElementAt(int index) { return values[index]; } }); scrollPane.setViewportView(list); File file = new File(".systemapps.txt"); if (file.exists() && !file.isDirectory()) { file.delete(); } AppStatus.setText("App has been uninstalled successfully"); SystemAppUninstallDone .setIcon(new ImageIcon(Interface.class.getResource("/graphics/Smalldone.png"))); btnUninstall.setSelected(false); } catch (Exception e1) { System.err.println(e1); } } } }); btnUninstall.setBounds(26, 327, 107, 27); contentPane.add(btnUninstall); JButton btnRefresh = new JButton("Refresh"); btnRefresh.setToolTipText("Refresh the apps list"); btnRefresh.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { Process p1 = Runtime.getRuntime().exec("adb shell ls /system/app/ > /sdcard/.systemapps.txt"); p1.waitFor(); Process p2 = Runtime.getRuntime().exec("adb pull /sdcard/.systemapps.txt"); p2.waitFor(); Process p3 = Runtime.getRuntime().exec("adb shell rm /sdcard/.systemapps.txt"); p3.waitFor(); lines = IOUtils.readLines(new FileInputStream(".systemapps.txt")); values = new String[lines.size()]; values = lines.toArray(values); list = new JList(); list.setModel(new AbstractListModel() { public int getSize() { return values.length; } public Object getElementAt(int index) { return values[index]; } }); scrollPane.setViewportView(list); File file = new File(".systemapps.txt"); if (file.exists() && !file.isDirectory()) { file.delete(); } } catch (Exception e1) { System.err.println(e1); } } }); btnRefresh.setBounds(344, 327, 107, 27); contentPane.add(btnRefresh); try { Process p1 = Runtime.getRuntime().exec("adb shell ls /system/app/ > /sdcard/.systemapps.txt"); p1.waitFor(); Process p2 = Runtime.getRuntime().exec("adb pull /sdcard/.systemapps.txt"); p2.waitFor(); Process p3 = Runtime.getRuntime().exec("adb shell rm /sdcard/.systemapps.txt"); p3.waitFor(); lines = IOUtils.readLines(new FileInputStream(".systemapps.txt")); values = new String[lines.size()]; values = lines.toArray(values); list = new JList(); list.setModel(new AbstractListModel() { public int getSize() { return values.length; } public Object getElementAt(int index) { return values[index]; } }); scrollPane.setViewportView(list); JLabel lblNewLabel = new JLabel("Note: You should also remove app's odex file if it exists"); lblNewLabel.setBounds(25, 374, 438, 17); contentPane.add(lblNewLabel); JLabel label = new JLabel("Needs root and does not work on production android builds!"); label.setBounds(25, 413, 454, 17); contentPane.add(label); File file = new File(".systemapps.txt"); if (file.exists() && !file.isDirectory()) { file.delete(); } } catch (Exception e) { System.err.println(e); } }
From source file:ml.shifu.shifu.core.binning.EqualPopulationBinningTest.java
@Test public void testUsageAge() throws IOException { EqualPopulationBinning binning = new EqualPopulationBinning(10); List<String> usageList = IOUtils .readLines(new FileInputStream("src/test/resources/example/binning-data/usage_age.txt")); for (String data : usageList) { binning.addData(data);/*w ww . ja v a2s .c o m*/ } List<Double> binBoundary = binning.getDataBin(); Assert.assertTrue(binBoundary.size() > 1); }
From source file:dpcs.UninstallPrivApps.java
@SuppressWarnings({ "unchecked", "rawtypes", "deprecation" }) public UninstallPrivApps() { setResizable(false);//from w ww . ja v a2 s.com setTitle("Uninstall Priv-apps"); setIconImage( Toolkit.getDefaultToolkit().getImage(UninstallSystemApps.class.getResource("/graphics/Icon.png"))); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setBounds(100, 100, 482, 500); contentPane = new JPanel(); contentPane.setBackground(Color.WHITE); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(null); JLabel AppStatus = new JLabel(""); AppStatus.setBounds(8, 404, 456, 17); contentPane.add(AppStatus); PrivAppUninstallDone = new JLabel(""); PrivAppUninstallDone.setText(""); PrivAppUninstallDone.setBounds(151, 312, 186, 56); contentPane.add(PrivAppUninstallDone); JLabel lblSelect = new JLabel("Select an app to remove"); lblSelect.setBounds(25, 12, 405, 17); contentPane.add(lblSelect); JScrollPane scrollPane = new JScrollPane(); scrollPane.setBounds(22, 41, 428, 259); contentPane.add(scrollPane); final JButton btnUninstall = new JButton("Uninstall"); btnUninstall.setToolTipText("Uninstall the selected app"); btnUninstall.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { PrivAppUninstallDone.setText(""); if (list.getSelectedValue() == null) { JOptionPane.showMessageDialog(null, "Please select an app first"); } else { try { AppStatus.setText("Uninstalling..."); Process p1 = Runtime.getRuntime().exec("adb remount"); p1.waitFor(); String[] commands = new String[3]; commands[0] = "adb shell su -c rm -r"; commands[1] = "/system/priv-app/"; commands[2] = " " + list.getSelectedValue(); Process p2 = Runtime.getRuntime().exec(commands, null); p2.waitFor(); Process p3 = Runtime.getRuntime() .exec("adb shell ls /system/priv-app/ > /sdcard/.privapps.txt"); p3.waitFor(); Process p4 = Runtime.getRuntime().exec("adb pull /sdcard/.privapps.txt"); p4.waitFor(); Process p5 = Runtime.getRuntime().exec("adb shell rm /sdcard/.privapps.txt"); p5.waitFor(); lines = IOUtils.readLines(new FileInputStream(".privapps.txt")); values = new String[lines.size()]; values = lines.toArray(values); list = new JList(); list.setModel(new AbstractListModel() { public int getSize() { return values.length; } public Object getElementAt(int index) { return values[index]; } }); scrollPane.setViewportView(list); File file = new File(".privapps.txt"); if (file.exists() && !file.isDirectory()) { file.delete(); } AppStatus.setText("App has been uninstalled successfully"); PrivAppUninstallDone .setIcon(new ImageIcon(Interface.class.getResource("/graphics/Smalldone.png"))); btnUninstall.setSelected(false); } catch (Exception e1) { System.err.println(e1); } } } }); btnUninstall.setBounds(26, 327, 107, 27); contentPane.add(btnUninstall); JButton btnRefresh = new JButton("Refresh"); btnRefresh.setToolTipText("Refresh the apps list"); btnRefresh.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { Process p1 = Runtime.getRuntime() .exec("adb shell ls /system/priv-app/ > /sdcard/.privapps.txt"); p1.waitFor(); Process p2 = Runtime.getRuntime().exec("adb pull /sdcard/.privapps.txt"); p2.waitFor(); Process p3 = Runtime.getRuntime().exec("adb shell rm /sdcard/.privapps.txt"); p3.waitFor(); lines = IOUtils.readLines(new FileInputStream(".privapps.txt")); values = new String[lines.size()]; values = lines.toArray(values); list = new JList(); list.setModel(new AbstractListModel() { public int getSize() { return values.length; } public Object getElementAt(int index) { return values[index]; } }); scrollPane.setViewportView(list); File file = new File(".privapps.txt"); if (file.exists() && !file.isDirectory()) { file.delete(); } } catch (Exception e1) { System.err.println(e1); } } }); btnRefresh.setBounds(344, 327, 107, 27); contentPane.add(btnRefresh); try { Process p1 = Runtime.getRuntime().exec("adb shell ls /system/priv-app/ > /sdcard/.privapps.txt"); p1.waitFor(); Process p2 = Runtime.getRuntime().exec("adb pull /sdcard/.privapps.txt"); p2.waitFor(); Process p3 = Runtime.getRuntime().exec("adb shell rm /sdcard/.privapps.txt"); p3.waitFor(); lines = IOUtils.readLines(new FileInputStream(".privapps.txt")); values = new String[lines.size()]; values = lines.toArray(values); list = new JList(); list.setModel(new AbstractListModel() { public int getSize() { return values.length; } public Object getElementAt(int index) { return values[index]; } }); scrollPane.setViewportView(list); JLabel lblNewLabel = new JLabel("Note: You should also remove app's odex file if it exits "); lblNewLabel.setBounds(25, 374, 438, 17); contentPane.add(lblNewLabel); JLabel lblNeedsRootAnd = new JLabel("Needs root and does not work on production android builds!"); lblNeedsRootAnd.setBounds(25, 426, 454, 17); contentPane.add(lblNeedsRootAnd); JLabel lblOnlyForAndroid = new JLabel("Uninstallation only for android 4.4.x and higher!"); lblOnlyForAndroid.setBounds(8, 452, 450, 15); contentPane.add(lblOnlyForAndroid); File file = new File(".privapps.txt"); if (file.exists() && !file.isDirectory()) { file.delete(); } } catch (Exception e) { System.err.println(e); } }