public void printAllMetrics(String prefix) { List<String> storeNames = new ArrayList<>(); storeNames.add(EDGESTORE_NAME); storeNames.add(INDEXSTORE_NAME); storeNames.add(ID_STORE_NAME); storeNames.add(METRICS_STOREMANAGER_NAME); if (storeUsesConsistentKeyLocker()) { storeNames.add(EDGESTORE_NAME+LOCK_STORE_SUFFIX); storeNames.add(INDEXSTORE_NAME+LOCK_STORE_SUFFIX); } for (String store : storeNames) { System.out.println("######## Store: " + store + " (" + prefix + ")"); for (String operation : MetricInstrumentedStore.OPERATION_NAMES) { System.out.println("-- Operation: " + operation); System.out.print("\t"); System.out.println(metric.getCounter(prefix, store, operation, MetricInstrumentedStore.M_CALLS).getCount()); System.out.print("\t"); System.out.println(metric.getTimer(prefix, store, operation, MetricInstrumentedStore.M_TIME).getMeanRate()); if (operation==MetricInstrumentedStore.M_GET_SLICE) { System.out.print("\t"); System.out.println(metric.getCounter(prefix, store, operation, MetricInstrumentedStore.M_ENTRIES_COUNT).getCount()); } } } }
morphoSpec.activate(MorphoFeatureType.valueOf(feature)); System.out.println("Language: " + language.toString()); System.out.println("Features: " + args[1]); System.out.print("Loading training trees..."); List<Tree> trainTrees = new ArrayList<>(19000); Index<String> wordIndex = new HashIndex<>(); Index<String> tagIndex = new HashIndex<>(); System.out.print("Collecting sufficient statistics for lexicon..."); FactoredLexicon lexicon = new FactoredLexicon(options, morphoSpec, wordIndex, tagIndex); lexicon.initializeTraining(trainTrees.size()); lexicon.train(trainTrees, null); lexicon.finishTraining(); System.out.println("Done!"); trainTrees = null; System.out.print("Loading tuning set..."); List<FactoredLexiconEvent> tuningSet = getTuningSet(devTreebank, lexicon, tlpp); System.out.printf("...Done! (%d events)%n", tuningSet.size()); System.err.printf("%n%nACCURACY: %.2f%n%n", acc*100.0); log.info("% of errors by type:"); List<String> biggestKeys = new ArrayList<>(errors.keySet()); Collections.sort(biggestKeys, Counters.toComparator(errors, false, true)); Counters.normalize(errors);
public static void main( String [] args ) throws IOException { fileQuickSort( new File("input"), new File("output")); System.out.println(); Scanner scanner = new Scanner( new BufferedInputStream( new FileInputStream( inputFile ), MAX_SIZE)); scanner.useDelimiter(","); System.out.print("-"); PrintStream greater = createPrintStream(greaterFile); PrintStream target = null; int pivot = scanner.nextInt(); int current = scanner.nextInt(); System.out.print("."); List<Integer> smallFileIntegers = new ArrayList<Integer>(); smallFileIntegers.add( scanner.nextInt() );
/** * @param service * @param input */ private static void getPersonDetails(final Scanner scanner,final PersonService service) { while(true) { System.out.print("Please enter the name of the person and press<enter>: "); String input = scanner.nextLine(); final List<Person> personList = service.findPersonByName(input); if(personList != null && !personList.isEmpty()) { for(Person person:personList) { System.out.print( String.format("Person found - Person Id: '%d', Person Name is: '%s', Gender: '%s'", person.getPersonId(),person.getName(), person.getGender())); System.out.println(String.format(", Date of birth: '%1$td/%1$tm/%1$tC%1$ty'", person.getDateOfBirth())); } } else { System.out.println( String.format("No Person record found for name: '%s'.", input)); } System.out.print("Do you want to find another person? (y/n)"); String choice = scanner.nextLine(); if(!"y".equalsIgnoreCase(choice)) { break; } } } }
public static void walk(String folderPath, Handler handler) { long start = System.currentTimeMillis(); List<File> fileList = IOUtil.fileList(folderPath); int i = 0; for (File file : fileList) { System.out.print(file); Document document = convert2Document(file); System.out.println(" " + ++i + " / " + fileList.size()); handler.handle(document); } System.out.printf("花费时间%d ms\n", System.currentTimeMillis() - start); }
import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class TestScanner { public static void main(String[] args) throws FileNotFoundException { Scanner scanner = new Scanner(new File("/Users/pankaj/abc.csv")); scanner.useDelimiter(","); while(scanner.hasNext()){ System.out.print(scanner.next()+"|"); } scanner.close(); } }
int nnames; String names[]; System.out.print("How many names are you going to save: "); Scanner in = new Scanner(System.in); nnames = Integer.parseInt(in.nextLine().trim()); names = new String[nnames]; for (int i = 0; i < names.length; i++){ System.out.print("Type a name: "); names[i] = in.nextLine(); }
try (Scanner in = new Scanner(System.in)) { while (in.hasNextLine()) { try { String line = in.nextLine(); Scanner lineScan = new Scanner(line); BigDecimal moneyInput = lineScan.nextBigDecimal(); String currency = lineScan.next(); // do something } catch (NoSuchElementException | IllegalStateException e) { System.err.print("Please enter the VALUE followed by the CURRENCY"); } } }
List<String> successfulTags = new ArrayList<>(); Set<String> tags = new TreeSet<>(); tags.addAll(allWords.keySet()); if (numTraining == numTotal && numTraining > 0) successfulTags.add(tag); System.out.println(tag + " " + numTraining + " " + numTotal); if (printWords) { Set<String> trainingSet = trainingWords.get(tag); Set<String> allSet = allWords.get(tag); for (String word : trainingSet) { System.out.print(" " + word); System.out.println(); System.out.print(" *"); for (String word : allWords.get(tag)) { if (!trainingSet.contains(word)) { System.out.print(" " + word); System.out.println();
Scanner sc = new Scanner(System.in); System.out.print("Enter number 1: "); while (!sc.hasNextInt()) sc.next(); int num1 = sc.nextInt(); int num2; System.out.print("Enter number 2: "); do { while (!sc.hasNextInt()) sc.next(); num2 = sc.nextInt(); } while (num2 < num1); System.out.println(num1 + " " + num2);
private static void createPersonDetails(final Scanner scanner,PersonService service) { while(true) { System.out.print("\nEnter the Person's name:"); String name = scanner.nextLine(); Gender gender; while(true) { System.out.print("Enter the Person's gender(M/F):"); String genderStr = scanner.nextLine(); if("m".equalsIgnoreCase(genderStr) || "f".equalsIgnoreCase(genderStr)) { gender = Gender.getGenderByIdentifier(genderStr.toUpperCase()); SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy"); while(true) { System.out.print("Enter the Person's Date of birth in DD/MM/YYYY format:"); String dobStr = scanner.nextLine(); try { dateOfBirth = format.parse(dobStr); person.setName(name); person = service.createPerson(person); System.out.println("Created person record with id: " + person.getPersonId()); System.out.print("Do you want to create another person? (y/n)"); String choice = scanner.nextLine(); if(!"y".equalsIgnoreCase(choice)) {
private Person readNewPerson(PrintStream out, Scanner scanner) { Person p = new Person(); out.print("Person name (NULL for null): "); p.setName(convertString(scanner.nextLine(), "")); out.print("Person surname (NULL for null): "); p.setSurname(convertString(scanner.nextLine(), "")); out.print("Person address id (NULL for null): "); readAndSetAddress(scanner, p); return p; }
public static void main(String[] args) { List<String> data = new ArrayList<>(); data.add("1"); data.add("2"); data.add("3"); data.add("4"); data.add("5"); List<List<String>> result = getCom(data); for (List<String> item : result) { for (String sub : item) { System.out.print(sub + " "); } System.out.println(""); } }