List of usage examples for java.lang String length
public int length()
From source file:com.redhat.poc.jdg.bankofchina.function.TestCase412RemoteMultiThreads.java
public static void main(String[] args) throws Exception { CommandLine commandLine;//from w w w. j av a2 s . co m Options options = new Options(); options.addOption("s", true, "The start csv file number option"); options.addOption("e", true, "The end csv file number option"); BasicParser parser = new BasicParser(); parser.parse(options, args); commandLine = parser.parse(options, args); if (commandLine.getOptions().length > 0) { if (commandLine.hasOption("s")) { String start = commandLine.getOptionValue("s"); if (start != null && start.length() > 0) { csvFileStart = Integer.parseInt(start); } } if (commandLine.hasOption("e")) { String end = commandLine.getOptionValue("e"); if (end != null && end.length() > 0) { csvFileEnd = Integer.parseInt(end); } } } System.out.println( "%%%%%%%%% csv ?, ?, ?(ms)," + new Date().getTime()); for (int i = csvFileStart; i <= csvFileEnd; i++) { new TestCase412RemoteMultiThreads(i).start(); } }
From source file:com.heliosdecompiler.appifier.Appifier.java
public static void main(String[] args) throws Throwable { if (args.length == 0) { System.out.println("An input JAR must be specified"); return;/*from w w w . j a v a2 s . c om*/ } File in = new File(args[0]); if (!in.exists()) { System.out.println("Input not found"); return; } String outName = args[0]; outName = outName.substring(0, outName.length() - ".jar".length()) + "-appified.jar"; File out = new File(outName); if (out.exists()) { if (!out.delete()) { System.out.println("Could not delete out file"); return; } } try (ZipOutputStream outstream = new ZipOutputStream(new FileOutputStream(out)); ZipFile zipFile = new ZipFile(in)) { { ZipEntry systemHook = new ZipEntry("com/heliosdecompiler/appifier/SystemHook.class"); outstream.putNextEntry(systemHook); outstream.write(SystemHookDump.dump()); outstream.closeEntry(); } Enumeration<? extends ZipEntry> enumeration = zipFile.entries(); while (enumeration.hasMoreElements()) { ZipEntry next = enumeration.nextElement(); if (!next.isDirectory()) { ZipEntry result = new ZipEntry(next.getName()); outstream.putNextEntry(result); if (next.getName().endsWith(".class")) { byte[] classBytes = IOUtils.toByteArray(zipFile.getInputStream(next)); outstream.write(transform(classBytes)); } else { IOUtils.copy(zipFile.getInputStream(next), outstream); } outstream.closeEntry(); } } } }
From source file:com.redhat.poc.jdg.bankofchina.performance.TestCase52RemoteMultiThreads.java
public static void main(String[] args) throws Exception { CommandLine commandLine;/*from w ww. j a va2 s.c o m*/ Options options = new Options(); options.addOption("n", true, "The read thread numbers option"); options.addOption("t", true, "The thread read times option"); BasicParser parser = new BasicParser(); parser.parse(options, args); commandLine = parser.parse(options, args); if (commandLine.getOptions().length > 0) { if (commandLine.hasOption("n")) { String numbers = commandLine.getOptionValue("n"); if (numbers != null && numbers.length() > 0) { writeThreadNumbers = Integer.parseInt(numbers); } } if (commandLine.hasOption("t")) { String times = commandLine.getOptionValue("t"); if (times != null && times.length() > 0) { threadWriteTimes = Integer.parseInt(times); } } } System.out.println(); System.out.println("%%%%%%%%% userid.csv %%%%%%%%%"); LoadUserIdList(); randomPoolSize = userIdList.size(); System.out.println( "%%%%%%%%% ? userid.csv , " + randomPoolSize + " ?? %%%%%%%%%"); randomPoolSizeByThread = randomPoolSize / writeThreadNumbers; System.out.println(); System.out.println( "%%%%%%%%% ?, " + writeThreadNumbers + ", , ??, " + threadWriteTimes + " ,?, ?(ms)," + new Date().getTime()); for (int i = 0; i < writeThreadNumbers; i++) { new TestCase52RemoteMultiThreads(i * randomPoolSizeByThread).start(); } }
From source file:com.redhat.poc.jdg.bankofchina.performance.TestCase51RemoteMultiThreads.java
public static void main(String[] args) throws Exception { CommandLine commandLine;//from www . j a va 2 s . c o m Options options = new Options(); options.addOption("n", true, "The read thread numbers option"); options.addOption("t", true, "The thread read times option"); BasicParser parser = new BasicParser(); parser.parse(options, args); commandLine = parser.parse(options, args); if (commandLine.getOptions().length > 0) { if (commandLine.hasOption("n")) { String numbers = commandLine.getOptionValue("n"); if (numbers != null && numbers.length() > 0) { readThreadNumbers = Integer.parseInt(numbers); } } if (commandLine.hasOption("t")) { String times = commandLine.getOptionValue("t"); if (times != null && times.length() > 0) { threadReadTimes = Integer.parseInt(times); } } } System.out.println(); System.out.println("%%%%%%%%% userid.csv %%%%%%%%%"); LoadUserIdList(); randomPoolSize = userIdList.size(); System.out.println( "%%%%%%%%% ? userid.csv , " + randomPoolSize + " ?? %%%%%%%%%"); randomPoolSizeByThread = randomPoolSize / readThreadNumbers; System.out.println(); System.out.println( "%%%%%%%%% ?, " + readThreadNumbers + " ,, ???, " + threadReadTimes + " ,?, ?(ms)," + new Date().getTime()); for (int i = 0; i < readThreadNumbers; i++) { new TestCase51RemoteMultiThreads(i * randomPoolSizeByThread).start(); } }
From source file:com.redhat.poc.jdg.bankofchina.performance.TestCase531RemoteMultiThreads.java
public static void main(String[] args) throws Exception { CommandLine commandLine;/*from w w w. j a va 2 s .c o m*/ Options options = new Options(); options.addOption("n", true, "The read thread numbers option"); options.addOption("t", true, "The thread read times option"); BasicParser parser = new BasicParser(); parser.parse(options, args); commandLine = parser.parse(options, args); if (commandLine.getOptions().length > 0) { if (commandLine.hasOption("n")) { String numbers = commandLine.getOptionValue("n"); if (numbers != null && numbers.length() > 0) { readThreadNumbers = Integer.parseInt(numbers); } } if (commandLine.hasOption("t")) { String times = commandLine.getOptionValue("t"); if (times != null && times.length() > 0) { threadReadTimes = Integer.parseInt(times); } } } System.out.println(); System.out.println("%%%%%%%%% userid.csv %%%%%%%%%"); LoadUserIdList(); randomPoolSize = userIdList.size(); System.out.println( "%%%%%%%%% ? userid.csv , " + randomPoolSize + " ?? %%%%%%%%%"); randomPoolSizeByThread = randomPoolSize / readThreadNumbers; System.out.println(); System.out.println( "%%%%%%%%% ?, " + readThreadNumbers + " ,, ???, " + threadReadTimes + " ,?, ?(ms)," + new Date().getTime()); for (int i = 0; i < readThreadNumbers; i++) { new TestCase531RemoteMultiThreads(i * randomPoolSizeByThread).start(); } }
From source file:com.redhat.poc.jdg.bankofchina.performance.TestCase532RemoteMultiThreads.java
public static void main(String[] args) throws Exception { CommandLine commandLine;/*from w w w . j ava2 s . com*/ Options options = new Options(); options.addOption("n", true, "The read thread numbers option"); options.addOption("t", true, "The thread read times option"); BasicParser parser = new BasicParser(); parser.parse(options, args); commandLine = parser.parse(options, args); if (commandLine.getOptions().length > 0) { if (commandLine.hasOption("n")) { String numbers = commandLine.getOptionValue("n"); if (numbers != null && numbers.length() > 0) { writeThreadNumbers = Integer.parseInt(numbers); } } if (commandLine.hasOption("t")) { String times = commandLine.getOptionValue("t"); if (times != null && times.length() > 0) { threadWriteTimes = Integer.parseInt(times); } } } System.out.println(); System.out.println("%%%%%%%%% userid.csv %%%%%%%%%"); LoadUserIdList(); randomPoolSize = userIdList.size(); System.out.println( "%%%%%%%%% ? userid.csv , " + randomPoolSize + " ?? %%%%%%%%%"); randomPoolSizeByThread = randomPoolSize / writeThreadNumbers; System.out.println(); System.out.println( "%%%%%%%%% ?, " + writeThreadNumbers + ", , ??, " + threadWriteTimes + ", ?, ?(ms)," + new Date().getTime()); for (int i = 0; i < writeThreadNumbers; i++) { new TestCase532RemoteMultiThreads(i * randomPoolSizeByThread).start(); } }
From source file:MainClass.java
public static void main(String args[]) { String secondString = "1, 2, 3, 4, 5, 6, 7, 8"; String output = "String split at commas: ["; String[] results = secondString.split(",\\s*"); // split on commas for (String string : results) output += "\"" + string + "\", "; output = output.substring(0, output.length() - 2) + "]"; System.out.println(output);//from ww w. j a v a 2 s. c o m }
From source file:com.javacreed.examples.sql.Example3.java
public static void main(final String[] args) throws Exception { try (BasicDataSource dataSource = DatabaseUtils.createDataSource(); Connection connection = dataSource.getConnection()) { final ExampleTest test = new ExampleTest(connection, "compressed_table", "compressed") { @Override/*w w w . j a v a 2 s . c o m*/ protected String parseRow(final ResultSet resultSet) throws Exception { try (InputStream in = new LZ4BlockInputStream(resultSet.getBinaryStream("compressed"))) { return IOUtils.toString(in, "UTF-8"); } } @Override protected void setPreparedStatement(final String data, final PreparedStatement statement) throws Exception { final ByteArrayOutputStream baos = new ByteArrayOutputStream(data.length()); try (OutputStream out = new LZ4BlockOutputStream(baos)) { out.write(data.getBytes("UTF-8")); } statement.setBinaryStream(1, new ByteArrayInputStream(baos.toByteArray())); } }; test.runTest(); } Example3.LOGGER.debug("Done"); }
From source file:com.foxykeep.parcelablecodegenerator.Main.java
public static void main(String[] args) { File fileInputDir = new File("input"); if (!fileInputDir.exists() || !fileInputDir.isDirectory()) { return;/*ww w. j a v a 2 s .c o m*/ } ArrayList<FileInfo> fileInfoList = new ArrayList<FileInfo>(); findJsonFiles(fileInputDir, null, fileInfoList); StringBuilder sb = new StringBuilder(); // For each file in the input folder for (FileInfo fileInfo : fileInfoList) { String fileName = fileInfo.file.getName(); System.out.println("Generating code for " + fileName); char[] buffer = new char[2048]; sb.setLength(0); Reader in; try { in = new InputStreamReader(new FileInputStream(fileInfo.file), "UTF-8"); int read; do { read = in.read(buffer, 0, buffer.length); if (read != -1) { sb.append(buffer, 0, read); } } while (read >= 0); } catch (UnsupportedEncodingException e) { e.printStackTrace(); return; } catch (FileNotFoundException e) { e.printStackTrace(); return; } catch (IOException e) { e.printStackTrace(); return; } String content = sb.toString(); if (content.length() == 0) { System.out.println("file is empty."); return; } try { JSONObject root = new JSONObject(content); // Classes generation String classPackage, className, superClassPackage, superClassName; boolean isSuperClassParcelable, hasSubClasses, isAbstract; classPackage = root.getString("package"); className = root.getString("name"); superClassPackage = JsonUtils.getStringFixFalseNull(root, "superClassPackage"); superClassName = JsonUtils.getStringFixFalseNull(root, "superClassName"); isSuperClassParcelable = root.optBoolean("isSuperClassParcelable"); hasSubClasses = root.optBoolean("hasSubClasses"); if (hasSubClasses) { isAbstract = root.optBoolean("isAbstract"); } else { isAbstract = false; } JSONArray fieldJsonArray = root.optJSONArray("fields"); ArrayList<FieldData> fieldDataList; if (fieldJsonArray != null) { fieldDataList = FieldData.getFieldsData(fieldJsonArray); } else { fieldDataList = new ArrayList<FieldData>(); } // Parcelable generation ParcelableGenerator.generate(fileInfo.dirPath, classPackage, className, superClassPackage, superClassName, isSuperClassParcelable, hasSubClasses, isAbstract, fieldDataList); } catch (JSONException e) { e.printStackTrace(); return; } } }
From source file:com.javacreed.examples.sql.Example4.java
public static void main(final String[] args) throws Exception { try (BasicDataSource dataSource = DatabaseUtils.createDataSource(); Connection connection = dataSource.getConnection()) { final ExampleTest test = new ExampleTest(connection, "compressed_table", "compressed") { @Override//from w ww . ja v a2 s . c o m protected String parseRow(final ResultSet resultSet) throws Exception { try (InputStream in = new LZ4BlockInputStream( CryptoUtils.wrapInToCipheredInputStream(resultSet.getBinaryStream("compressed")))) { return IOUtils.toString(in, "UTF-8"); } } @Override protected void setPreparedStatement(final String data, final PreparedStatement statement) throws Exception { final ByteArrayOutputStream baos = new ByteArrayOutputStream(data.length()); try (OutputStream out = new LZ4BlockOutputStream( CryptoUtils.wrapInToCipheredOutputStream(baos))) { out.write(data.getBytes("UTF-8")); } statement.setBinaryStream(1, new ByteArrayInputStream(baos.toByteArray())); } }; test.runTest(); } Example4.LOGGER.debug("Done"); }