List of usage examples for java.lang String replaceAll
public String replaceAll(String regex, String replacement)
From source file:com.rover12421.shaka.cli.Main.java
public static void main(String[] args) throws Exception { boolean smali = false; boolean baksmali = false; String[] realyArgs = args;/*from www. j av a 2s.co m*/ if (args.length > 0) { String cmd = args[0]; if (cmd.equalsIgnoreCase("s") || cmd.equalsIgnoreCase("smali")) { smali = true; } else if (cmd.equalsIgnoreCase("bs") || cmd.equalsIgnoreCase("baksmali")) { baksmali = true; } if (smali || baksmali) { realyArgs = new String[args.length - 1]; System.arraycopy(args, 1, realyArgs, 0, realyArgs.length); } } // cli parser CommandLineParser parser = new IgnoreUnkownArgsPosixParser(); CommandLine commandLine; Option language = CommandLineArgEnum.LANGUAGE.getOption(); Options options = new Options(); options.addOption(language); try { commandLine = parser.parse(options, args, false); if (CommandLineArgEnum.LANGUAGE.hasMatch(commandLine)) { String lngStr = commandLine.getOptionValue(CommandLineArgEnum.LANGUAGE.getOpt()); Locale locale = Locale.forLanguageTag(lngStr); if (locale.toString().isEmpty()) { lngStr = lngStr.replaceAll("_", "-"); locale = Locale.forLanguageTag(lngStr); } MultiLanguageSupport.getInstance().setLang(locale); } } catch (Exception ex) { } if (smali) { smaliMainAj.setHookMain(ApktoolMainAj.getHookMain()); org.jf.smali.main.main(realyArgs); } else if (baksmali) { baksmaliMainAj.setHookMain(ApktoolMainAj.getHookMain()); org.jf.baksmali.main.main(realyArgs); } else { brut.apktool.Main.main(realyArgs); } }
From source file:com.adobe.aem.demomachine.Json2Csv.java
public static void main(String[] args) throws IOException { String inputFile1 = null;/*www .jav a 2s . com*/ String inputFile2 = null; String outputFile = null; HashMap<String, String> hmReportSuites = new HashMap<String, String>(); // Command line options for this tool Options options = new Options(); options.addOption("c", true, "Filename 1"); options.addOption("r", true, "Filename 2"); options.addOption("o", true, "Filename 3"); CommandLineParser parser = new BasicParser(); try { CommandLine cmd = parser.parse(options, args); if (cmd.hasOption("c")) { inputFile1 = cmd.getOptionValue("c"); } if (cmd.hasOption("r")) { inputFile2 = cmd.getOptionValue("r"); } if (cmd.hasOption("o")) { outputFile = cmd.getOptionValue("o"); } if (inputFile1 == null || inputFile1 == null || outputFile == null) { System.exit(-1); } } catch (ParseException ex) { logger.error(ex.getMessage()); } // List of customers and report suites for these customers String sInputFile1 = readFile(inputFile1, Charset.defaultCharset()); sInputFile1 = sInputFile1.replaceAll("ObjectId\\(\"([0-9a-z]*)\"\\)", "\"$1\""); // Processing the list of report suites for each customer try { JSONArray jCustomers = new JSONArray(sInputFile1.trim()); for (int i = 0, size = jCustomers.length(); i < size; i++) { JSONObject jCustomer = jCustomers.getJSONObject(i); Iterator<?> keys = jCustomer.keys(); String companyName = null; while (keys.hasNext()) { String key = (String) keys.next(); if (key.equals("company")) { companyName = jCustomer.getString(key); } } keys = jCustomer.keys(); while (keys.hasNext()) { String key = (String) keys.next(); if (key.equals("report_suites")) { JSONArray jReportSuites = jCustomer.getJSONArray(key); for (int j = 0, rSize = jReportSuites.length(); j < rSize; j++) { hmReportSuites.put(jReportSuites.getString(j), companyName); System.out.println(jReportSuites.get(j) + " for company " + companyName); } } } } // Creating the out put file PrintWriter writer = new PrintWriter(outputFile, "UTF-8"); writer.println("\"" + "Customer" + "\",\"" + "ReportSuite ID" + "\",\"" + "Number of Documents" + "\",\"" + "Last Updated" + "\""); // Processing the list of SOLR collections String sInputFile2 = readFile(inputFile2, Charset.defaultCharset()); sInputFile2 = sInputFile2.replaceAll("NumberLong\\(\"([0-9a-z]*)\"\\)", "\"$1\""); JSONObject jResults = new JSONObject(sInputFile2.trim()); JSONArray jCollections = jResults.getJSONArray("result"); for (int i = 0, size = jCollections.length(); i < size; i++) { JSONObject jCollection = jCollections.getJSONObject(i); String id = null; String number = null; String lastupdate = null; Iterator<?> keys = jCollection.keys(); while (keys.hasNext()) { String key = (String) keys.next(); if (key.equals("_id")) { id = jCollection.getString(key); } } keys = jCollection.keys(); while (keys.hasNext()) { String key = (String) keys.next(); if (key.equals("noOfDocs")) { number = jCollection.getString(key); } } keys = jCollection.keys(); while (keys.hasNext()) { String key = (String) keys.next(); if (key.equals("latestUpdateDate")) { lastupdate = jCollection.getString(key); } } Date d = new Date(Long.parseLong(lastupdate)); System.out.println(hmReportSuites.get(id) + "," + id + "," + number + "," + lastupdate + "," + new SimpleDateFormat("MM-dd-yyyy").format(d)); writer.println("\"" + hmReportSuites.get(id) + "\",\"" + id + "\",\"" + number + "\",\"" + new SimpleDateFormat("MM-dd-yyyy").format(d) + "\""); } writer.close(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:com.da.daum.DaumCafeBungParser.java
public static void main(String[] args) throws IOException { DaumCafeBungParser parser = new DaumCafeBungParser(); String listBody = "(?)^*~.txt"; listBody = listBody.replaceAll("\\*", "").replaceAll("\\*", ""); System.out.println(listBody); // FileUtils.writeStringToFile(new File(file), listBody, "utf-8"); //File file = new File("C:\\TEMP\\daum\\user\\Lak_view_.txt"); File file = new File("C:\\TEMP\\daum\\user\\Lak_list_1.txt"); listBody = FileUtils.readFileToString(file, "utf-8"); Map pageMap = new HashMap(); parser.setDaumListVoList(listBody, pageMap); //parser.setDaumView(listBody); }
From source file:com.da.daum.DaumCafeJw0Parser.java
public static void main(String[] args) throws IOException { DaumCafeJw0Parser parser = new DaumCafeJw0Parser(); String listBody = "(?)^*~.txt"; listBody = listBody.replaceAll("\\*", "").replaceAll("\\*", ""); System.out.println(listBody); // FileUtils.writeStringToFile(new File(file), listBody, "utf-8"); //File file = new File("C:\\TEMP\\daum\\user\\Lak_view_.txt"); File file = new File("C:\\TEMP\\daum\\user\\Lak_list_1.txt"); listBody = FileUtils.readFileToString(file, "utf-8"); Map pageMap = new HashMap(); parser.setDaumListVoList(listBody, pageMap); //parser.setDaumView(listBody); }
From source file:com.da.daum.DaumCafeLevelUpParser.java
public static void main(String[] args) throws IOException { DaumCafeLevelUpParser parser = new DaumCafeLevelUpParser(); String listBody = "(?)^*~.txt"; listBody = listBody.replaceAll("\\*", "").replaceAll("\\*", ""); System.out.println(listBody); // FileUtils.writeStringToFile(new File(file), listBody, "utf-8"); //File file = new File("C:\\TEMP\\daum\\user\\Lak_view_.txt"); File file = new File("C:\\TEMP\\daum\\user\\Lak_list_1.txt"); listBody = FileUtils.readFileToString(file, "utf-8"); Map pageMap = new HashMap(); parser.setDaumListVoList(listBody, pageMap); //parser.setDaumView(listBody); }
From source file:com.da.daum.DaumOk211Parser.java
public static void main(String[] args) throws IOException { DaumOk211Parser parser = new DaumOk211Parser(); String listBody = "(?)^*~.txt"; listBody = listBody.replaceAll("\\*", "").replaceAll("\\*", ""); System.out.println(listBody); // FileUtils.writeStringToFile(new File(file), listBody, "utf-8"); //File file = new File("C:\\TEMP\\daum\\user\\Lak_view_.txt"); File file = new File("C:\\TEMP\\daum\\user\\Lak_list_1.txt"); listBody = FileUtils.readFileToString(file, "utf-8"); Map pageMap = new HashMap(); parser.setDaumListVoList(listBody, pageMap); //parser.setDaumView(listBody); }
From source file:importer.handler.post.stages.SAXSplitter.java
public static void main(String[] args) { if (args.length == 1) { File f = new File(args[0]); byte[] data = new byte[(int) f.length()]; try {//w w w .ja v a 2 s . co m FileInputStream fis = new FileInputStream(f); fis.read(data); SAXSplitter ss = new SAXSplitter(); JSONArray jArr = ss.scan(new String(data, "UTF-8")); String jStr = jArr.toJSONString(); System.out.println(jStr.replaceAll("\\\\/", "/")); } catch (Exception e) { System.out.println(e.getMessage()); } } }
From source file:com.zf.decipher.DataEn.java
public static void main(String[] args) { try {// ww w . j ava 2 s.c o m System.out.println(DataEn.encrypt( "{\"robotId\":\"aabbcc\",\"clickTime\":\"1480919718696\",\"clickId\":\"ncbtest1480919718696\",\"clickUrl\":\"http://niuc.com.test\",\"referer\":\"http://test.referer\",\"trackingUrl\":\"http://test.tackingurl\",\"clickResult\":\"1\"}")); String s = DataEn.encrypt( "{\"robotId\":\"aabbcc\",\"clickTime\":\"1480919718696\",\"clickId\":\"ncbtest1480919718696\",\"clickUrl\":\"http://niuc.com.test\",\"referer\":\"http://test.referer\",\"trackingUrl\":\"http://test.tackingurl\",\"clickResult\":\"1\"}"); String ss = s.replaceAll("\n", "").replaceAll("\r", ""); System.out.println(s); System.out.println(ss); System.out.println(DataEn.decrypt( "NPiRPQU7MvYejbxHFcLvyINidHKwQHbAGzhhgAmmeywNOjfF7Za7meXLxTgVKq2YMxWz0Q8SMuiLyQ59t0Zet0qKQqrzf7R9Saff6aDvCWm2LjccLDeQtaVO9ltPFxt1LDW5RZEFNZuyx5zP5fVFXAfMNrdmKjQ+i0yM6DRZ8UcuO0jAWarCM7VLpII+nBTA1ojkyynMWueZjagqEP0rZbgSHENtKJfFZ4JB6cvYe9hChjfT0FPkyvhXP6moKjC0YFNF7oaOJ8RfQJy56/OY5g==")); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:mmllabvsdextractfeature.MMllabVSDExtractFeature.java
/** * @param args the command line arguments *//*from w w w . j a v a2 s.com*/ public static void main(String[] args) throws IOException { // TODO code application logic here MMllabVSDExtractFeature hello = new MMllabVSDExtractFeature(); FileStructer metdata = new FileStructer(); //Utility utilityClassIni = new Utility(); FrameStructer frameStructer = new FrameStructer(); /* Flow : 1. Read metdata file 2. Untar folder: -1 Shot content 25 frame -1 folder 50 shot Process with 1 shot: - Resize All image 1 shot --> delete orginal. - Extract feature 25 frame - Pooling Max and aveg. - Delete Image, feature - zip file Feature 3. Delete File. */ // Load metadata File String dir = "/media/data1"; String metadataFileDir = "/media/data1/metdata/devel2011-new.lst"; ArrayList<FileStructer> listFileFromMetadata = metdata.readMetadata(metadataFileDir); // String test = utilityClass.readTextFile("C:\\Users\\tiendv\\Downloads\\VSD_devel2011_1.shot_1.RKF_1.Frame_1.txt"); // ArrayList <String> testFeatureSave = utilityClass.SplitUsingTokenizerWithLineArrayList(test, " "); // utilityClass.writeToFile("C:\\Users\\tiendv\\Downloads\\VSD_devel2011_1.shot_1.txt", testFeatureSave); // System.out.println(test); for (int i = 0; i < listFileFromMetadata.size(); i++) { Utility utilityClass = new Utility(); //Un zip file String folderName = listFileFromMetadata.get(i).getWholeFolderName(); String nameZipFile = dir + "/" + folderName + "/" + listFileFromMetadata.get(i).getNameZipFileName() + ".tar"; nameZipFile = nameZipFile.replaceAll("\\s", ""); String outPutFolder = dir + "/" + folderName + "/" + listFileFromMetadata.get(i).getNameZipFileName(); outPutFolder = outPutFolder.replaceAll("\\s", ""); utilityClass.unTarFolder(UNTARSHFILE, nameZipFile, outPutFolder + "_"); // Resize all image in folder has been unzip utilityClass.createFolder(CREADFOLDER, outPutFolder); utilityClass.resizeWholeFolder(outPutFolder + "_", outPutFolder, resizeWidth, resizeHeight); utilityClass.deleteWholeFolder(DELETEFOLDER, outPutFolder + "_"); // Read all file from Folder has been unzip ArrayList<FrameStructer> allFrameInZipFolder = new ArrayList<>(); allFrameInZipFolder = frameStructer.getListFileInZipFolder(outPutFolder); System.out.println(allFrameInZipFolder.size()); // sort with shot ID Collections.sort(allFrameInZipFolder, FrameStructer.frameIDNo); // Loop with 1 shot int indexFrame = 0; for (int n = 0; n < allFrameInZipFolder.size() / 25; n++) { // Process with 1 ArrayList<String> nameAllFrameOneShot = new ArrayList<>(); String shotAndFolderName = new String(); for (; indexFrame < Math.min((n + 1) * 25, allFrameInZipFolder.size()); indexFrame++) { String imageForExtract = outPutFolder + "/" + allFrameInZipFolder.get(indexFrame).toFullName() + ".jpg"; shotAndFolderName = allFrameInZipFolder.get(indexFrame).shotName(); String resultNameAfterExtract = outPutFolder + "/" + allFrameInZipFolder.get(indexFrame).toFullName() + ".txt"; nameAllFrameOneShot.add(resultNameAfterExtract); // extract and Delete image file --> ouput image'feature utilityClass.excuteFeatureExtractionAnImage(EXTRACTFEATUREANDDELETESOURCEIMAGESHFILE, "0", CUDAOVERFEATPATH, imageForExtract, resultNameAfterExtract); } // Pooling // DenseMatrix64F resultMaTrixFeatureOneShot = utilityClass.buidEJMLMatrixFeatureOneShot(nameAllFrameOneShot); // utilityClass.savePoolingFeatureOneShotWithEJMLFromMatrix(resultMaTrixFeatureOneShot,outPutFolder,shotAndFolderName); utilityClass.buidPoolingFileWithOutMatrixFeatureOneShot(nameAllFrameOneShot, outPutFolder, shotAndFolderName); // Save A file for (int frameCount = 0; frameCount < nameAllFrameOneShot.size(); frameCount++) { // Delete feature extract file utilityClass.deletefile(DELETEFILE, nameAllFrameOneShot.get(frameCount)); } // Release one shot data nameAllFrameOneShot.clear(); System.out.print("The end of one's shot" + "\n" + n); } // Delete zip file utilityClass.deletefile(DELETEFILE, nameZipFile); // Zip Whole Folder /** * Extract 1 shot * Resize 25 frame with the same shotid --> delete orgra. * Extract 25 frame --> feature file --->delete * */ } }
From source file:ebay.Ebay.java
/** * @param args the command line arguments *///w w w . j av a 2 s . c o m public static void main(String[] args) { HttpClient client = null; HttpResponse response = null; BufferedReader rd = null; Document doc = null; String xml = ""; EbayDAO<Producto> db = new EbayDAO<>(Producto.class); String busqueda; while (true) { busqueda = JOptionPane.showInputDialog(null, "ingresa una busqueda"); if (busqueda != null) { busqueda = busqueda.replaceAll(" ", "%20"); try { client = new DefaultHttpClient(); /* peticion GET */ HttpGet request = new HttpGet("http://open.api.ebay.com/shopping?" + "callname=FindPopularItems" + "&appid=student11-6428-4bd4-ac0d-6ed9d84e345" + "&version=517&QueryKeywords=" + busqueda + "&siteid=0" + "&responseencoding=XML"); /* se ejecuta la peticion GET */ response = client.execute(request); rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); /* comienza la lectura de la respuesta a la peticion GET */ String line; while ((line = rd.readLine()) != null) { xml += line + "\n"; } } catch (IOException ex) { Logger.getLogger(Ebay.class.getName()).log(Level.SEVERE, null, ex); } /* creamos nuestro documentBulder(documento constructor) y obtenemos nuestro objeto documento apartir de documentBuilder */ try { DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); doc = documentBuilder.parse(new InputSource(new ByteArrayInputStream(xml.getBytes("utf-8")))); } catch (ParserConfigurationException | SAXException | IOException ex) { Logger.getLogger(Ebay.class.getName()).log(Level.SEVERE, null, ex); } Element raiz = doc.getDocumentElement(); if (raiz == null) { System.exit(0); } if (raiz.getElementsByTagName("Ack").item(0).getTextContent().equals("Success")) { NodeList array = raiz.getElementsByTagName("ItemArray").item(0).getChildNodes(); for (int i = 0; i < array.getLength(); ++i) { Node n = array.item(i); if (n.getNodeType() != Node.TEXT_NODE) { Producto p = new Producto(); if (((Element) n).getElementsByTagName("ItemID").item(0) != null) p.setId(new Long( ((Element) n).getElementsByTagName("ItemID").item(0).getTextContent())); if (((Element) n).getElementsByTagName("EndTime").item(0) != null) p.setEndtime( ((Element) n).getElementsByTagName("EndTime").item(0).getTextContent()); if (((Element) n).getElementsByTagName("ViewItemURLForNaturalSearch").item(0) != null) p.setViewurl(((Element) n).getElementsByTagName("ViewItemURLForNaturalSearch") .item(0).getTextContent()); if (((Element) n).getElementsByTagName("ListingType").item(0) != null) p.setListingtype( ((Element) n).getElementsByTagName("ListingType").item(0).getTextContent()); if (((Element) n).getElementsByTagName("GalleryURL").item(0) != null) p.setGalleryurl( ((Element) n).getElementsByTagName("GalleryURL").item(0).getTextContent()); if (((Element) n).getElementsByTagName("PrimaryCategoryID").item(0) != null) p.setPrimarycategoryid(new Integer(((Element) n) .getElementsByTagName("PrimaryCategoryID").item(0).getTextContent())); if (((Element) n).getElementsByTagName("PrimaryCategoryName").item(0) != null) p.setPrimarycategoryname(((Element) n).getElementsByTagName("PrimaryCategoryName") .item(0).getTextContent()); if (((Element) n).getElementsByTagName("BidCount").item(0) != null) p.setBidcount(new Integer( ((Element) n).getElementsByTagName("BidCount").item(0).getTextContent())); if (((Element) n).getElementsByTagName("ConvertedCurrentPrice").item(0) != null) p.setConvertedcurrentprice(new Double(((Element) n) .getElementsByTagName("ConvertedCurrentPrice").item(0).getTextContent())); if (((Element) n).getElementsByTagName("ListingStatus").item(0) != null) p.setListingstatus(((Element) n).getElementsByTagName("ListingStatus").item(0) .getTextContent()); if (((Element) n).getElementsByTagName("TimeLeft").item(0) != null) p.setTimeleft( ((Element) n).getElementsByTagName("TimeLeft").item(0).getTextContent()); if (((Element) n).getElementsByTagName("Title").item(0) != null) p.setTitle(((Element) n).getElementsByTagName("Title").item(0).getTextContent()); if (((Element) n).getElementsByTagName("ShippingServiceCost").item(0) != null) p.setShippingservicecost(new Double(((Element) n) .getElementsByTagName("ShippingServiceCost").item(0).getTextContent())); if (((Element) n).getElementsByTagName("ShippingType").item(0) != null) p.setShippingtype(((Element) n).getElementsByTagName("ShippingType").item(0) .getTextContent()); if (((Element) n).getElementsByTagName("WatchCount").item(0) != null) p.setWatchcount(new Integer( ((Element) n).getElementsByTagName("WatchCount").item(0).getTextContent())); if (((Element) n).getElementsByTagName("ListedShippingServiceCost").item(0) != null) p.setListedshippingservicecost( new Double(((Element) n).getElementsByTagName("ListedShippingServiceCost") .item(0).getTextContent())); try { db.insert(p); } catch (Exception e) { db.update(p); } } } } Ventana.crear(xml); } else System.exit(0); } }