本文整理了Java中java.io.PrintStream.print()
方法的一些代码示例,展示了PrintStream.print()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。PrintStream.print()
方法的具体详情如下:
包路径:java.io.PrintStream
类名称:PrintStream
方法名:print
[英]Prints the string representation of the char c.
[中]打印字符c的字符串表示形式。
代码示例来源:origin: libgdx/libgdx
public static void print (Object... objs) {
for (Object o : objs) {
System.out.print(o);
}
System.out.println();
}
}
代码示例来源:origin: apache/ignite
/**
* Provides a prompt, then reads a single line of text from the console.
*
* @param prompt text
* @return A string containing the line read from the console
*/
private String readLine(String prompt) {
System.out.print(prompt);
return IN.nextLine();
}
代码示例来源:origin: stackoverflow.com
int nnames;
String names[];
System.out.print("How many names are you going to save: ");
Scanner in = new Scanner(System.in);
nnames = in.nextInt();
names = new String[nnames];
in.nextLine();
for (int i = 0; i < names.length; i++){
System.out.print("Type a name: ");
names[i] = in.nextLine();
}
代码示例来源:origin: thinkaurelius/titan
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());
}
}
}
}
代码示例来源:origin: stanfordnlp/CoreNLP
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);
代码示例来源:origin: stackoverflow.com
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() );
代码示例来源:origin: spring-projects/spring-integration-samples
/**
* @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;
}
}
}
}
代码示例来源:origin: hankcs/HanLP
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);
}
代码示例来源:origin: stackoverflow.com
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();
}
}
代码示例来源:origin: stackoverflow.com
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();
}
代码示例来源:origin: stackoverflow.com
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");
}
}
}
代码示例来源:origin: stackoverflow.com
Scanner scan = new Scanner(System.in);
System.out.print("Enter a delay in seconds: ");
delay = scan.nextInt()*1000;
代码示例来源:origin: stanfordnlp/CoreNLP
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();
代码示例来源:origin: stackoverflow.com
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);
代码示例来源:origin: libgdx/libgdx
private void out (String message, int nesting) {
for (int i = 0; i < nesting; i++)
System.out.print(" ");
System.out.println(message);
}
代码示例来源:origin: spring-projects/spring-integration-samples
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)) {
代码示例来源:origin: stackoverflow.com
Scanner scanner = new Scanner (System.in);
System.out.print("Enter your name");
name = scanner.next(); // Get what the user types.
代码示例来源:origin: oracle/opengrok
private static void pauseToAwaitProfiler() {
Scanner scan = new Scanner(System.in);
String in;
do {
System.out.print("Start profiler. Continue (Y/N)? ");
in = scan.nextLine().toLowerCase(Locale.ROOT);
} while (!in.equals("y") && !in.equals("n"));
if (in.equals("n")) {
System.exit(1);
}
}
代码示例来源:origin: hibernate/hibernate-orm
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;
}
代码示例来源:origin: ysc/QuestionAnsweringSystem
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("");
}
}
内容来源于网络,如有侵权,请联系作者删除!