java.io.PrintStream.println()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(171)

本文整理了Java中java.io.PrintStream.println()方法的一些代码示例,展示了PrintStream.println()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。PrintStream.println()方法的具体详情如下:
包路径:java.io.PrintStream
类名称:PrintStream
方法名:println

PrintStream.println介绍

[英]Prints a newline.
[中]打印换行符。

代码示例

代码示例来源:origin: stackoverflow.com

try (Scanner scanner = new Scanner(response)) {
  String responseBody = scanner.useDelimiter("\\A").next();
  System.out.println(responseBody);
}

代码示例来源:origin: stackoverflow.com

List<String> stockList = new ArrayList<String>();
stockList.add("stock1");
stockList.add("stock2");

String[] stockArr = new String[stockList.size()];
stockArr = stockList.toArray(stockArr);

for(String s : stockArr)
  System.out.println(s);

代码示例来源: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: stackoverflow.com

List<String> strings = new ArrayList<String>()
strings.add("lol");
strings.add("cat");

Collections.sort(strings);
for (String s : strings) {
  System.out.println(s);
}
// Prints out "cat" and "lol"

代码示例来源:origin: stackoverflow.com

ArrayList aList = new ArrayList();
//Add elements to ArrayList object
aList.add("1");
aList.add("2");
aList.add("3");
aList.add("4");
aList.add("5");
Collections.reverse(aList);
System.out.println("After Reverse Order, ArrayList Contains : " + aList);

代码示例来源:origin: libgdx/libgdx

private String getAssetPath (GeneratorContext context) {
  ConfigurationProperty assetPathProperty = null;
  try {
    assetPathProperty = context.getPropertyOracle().getConfigurationProperty("gdx.assetpath");
  } catch (BadPropertyValueException e) {
    throw new RuntimeException(
      "No gdx.assetpath defined. Add <set-configuration-property name=\"gdx.assetpath\" value=\"relative/path/to/assets/\"/> to your GWT projects gwt.xml file");
  }
  if (assetPathProperty.getValues().size() == 0) {
    throw new RuntimeException(
      "No gdx.assetpath defined. Add <set-configuration-property name=\"gdx.assetpath\" value=\"relative/path/to/assets/\"/> to your GWT projects gwt.xml file");
  }
  String paths = assetPathProperty.getValues().get(0);
  if(paths == null) {
    throw new RuntimeException(
      "No gdx.assetpath defined. Add <set-configuration-property name=\"gdx.assetpath\" value=\"relative/path/to/assets/\"/> to your GWT projects gwt.xml file");
  } else {
    ArrayList<String> existingPaths = new ArrayList<String>();
    String[] tokens = paths.split(",");
    for(String token: tokens) {
      System.out.println(token);
      if(new FileWrapper(token).exists() || new FileWrapper("../" + token).exists()) {
        return token;
      }
    }
    throw new RuntimeException(
      "No valid gdx.assetpath defined. Fix <set-configuration-property name=\"gdx.assetpath\" value=\"relative/path/to/assets/\"/> in your GWT projects gwt.xml file");
  }
}

代码示例来源: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();
    scanner.close();
    lower.close();
    greater.close();
    System.out.print(".");
    List<Integer> smallFileIntegers = new ArrayList<Integer>();
      smallFileIntegers.add( scanner.nextInt() );
    scanner.close();

代码示例来源:origin: stackoverflow.com

String input = "1 fish 2 fish red fish blue fish";
Scanner s = new Scanner(input).useDelimiter("\\s*fish\\s*");
System.out.println(s.nextInt());
System.out.println(s.nextInt());
System.out.println(s.next());
System.out.println(s.next());
s.close();

代码示例来源:origin: stackoverflow.com

String[] arr = new String[1];
 arr[0] = "rohit";
 List<String> newList = Arrays.asList(arr);
 // Will throw `UnsupportedOperationException
 // newList.add("jain"); // Can't do this.
 ArrayList<String> updatableList = new ArrayList<String>();
 updatableList.addAll(newList); 
 updatableList.add("jain"); // OK this is fine. 
 System.out.println(newList);       // Prints [rohit]
 System.out.println(updatableList); //Prints [rohit, jain]

代码示例来源:origin: stackoverflow.com

Scanner sc = new Scanner(System.in);
System.out.println("Give me a bunch of numbers in a line (or 'exit')");
while (!sc.hasNext("exit")) {
  Scanner lineSc = new Scanner(sc.nextLine());
  int sum = 0;
  while (lineSc.hasNextInt()) {
    sum += lineSc.nextInt();
  }
  System.out.println("Sum is " + sum);
}

代码示例来源:origin: stackoverflow.com

// Substitute appropriate type.
ArrayList<...> a = new ArrayList<...>();

// Add elements to list.

// Generate an iterator. Start just after the last element.
ListIterator li = a.listIterator(a.size());

// Iterate in reverse.
while(li.hasPrevious()) {
 System.out.println(li.previous());
}

代码示例来源:origin: voldemort/voldemort

List<Integer> nodeIds = Lists.newArrayList();
System.out.print("\nNew metadata: \n" + value.toString() + "\n");
System.out.print("\nAffected nodes:\n");
System.out.format("+-------+------+---------------------------------+----------+---------+------------------+%n");
System.out.printf("|Id     |Zone  |Host                             |SocketPort|AdminPort|NumberOfPartitions|%n");
    nodeIds.add(node.getId());
    System.out.format("| %-5d | %-4d | %-31s | %-5d    | %-5d   | %-5d            |%n",
             node.getId(),
System.out.print("Do you want to proceed? [Y/N]: ");
Scanner in = new Scanner(System.in);
String choice = in.nextLine();
  return false;
} else {
  System.out.println("Incorrect response detected. Exiting.");
  return false;

代码示例来源:origin: stackoverflow.com

System.out.println("Enter your username: ");
Scanner scanner = new Scanner(System.in);
String username = scanner.nextLine();
System.out.println("Your username is " + username);

代码示例来源:origin: stackoverflow.com

Scanner reader = new Scanner(System.in);  // Reading from System.in
System.out.println("Enter a number: ");
int n = reader.nextInt(); // Scans the next token of the input as an int.

代码示例来源:origin: marytts/marytts

/**
 * Reads the Label file, the file which contains the Mary context features, creates an scanner object and calls getTargets
 *
 * @param LabFile
 *            LabFile
 * @param htsData
 *            htsData
 * @throws Exception
 *             Exception
 * @return targets
 */
public static List<Target> getTargetsFromFile(String LabFile, HMMData htsData) throws Exception {
  List<Target> targets = null;
  Scanner s = null;
  try {
    /* parse text in label file */
    s = new Scanner(new BufferedReader(new FileReader(LabFile)));
    targets = getTargets(s, htsData);
  } catch (FileNotFoundException e) {
    System.err.println("FileNotFoundException: " + e.getMessage());
  } finally {
    if (s != null)
      s.close();
  }
  return targets;
}

代码示例来源:origin: stackoverflow.com

public void readShapeData() throws IOException {
  Scanner in = new Scanner(System.in);
  try {
    System.out.println("Enter the width of the Rectangle: ");
    width = in.nextDouble();
    System.out.println("Enter the height of the Rectangle: ");
    height = in.nextDouble();
  } finally {
    in.close();
  }
}

代码示例来源:origin: stackoverflow.com

Scanner sc2 = null;
 try {
   sc2 = new Scanner(new File("translate.txt"));
 } catch (FileNotFoundException e) {
   e.printStackTrace();  
 }
 while (sc2.hasNextLine()) {
     Scanner s2 = new Scanner(sc2.nextLine());
   while (s2.hasNext()) {
     String s = s2.next();
     System.out.println(s);
   }
 }

代码示例来源:origin: stackoverflow.com

Scanner sc = new Scanner(System.in);
while (!sc.hasNext("exit")) {
  System.out.println(
    sc.hasNextInt() ? "(int) " + sc.nextInt() :
    sc.hasNextLong() ? "(long) " + sc.nextLong() :  
    sc.hasNextDouble() ? "(double) " + sc.nextDouble() :
    sc.hasNextBoolean() ? "(boolean) " + sc.nextBoolean() :
    "(String) " + sc.next()
  );
}

代码示例来源:origin: qiurunze123/miaosha

/**
 * 测试多表联合查询  in
 */
@RequestMapping(value = "/testTandUIn", produces = "text/html")
@ResponseBody
public void testTandUIn(){
  List<Integer> list = new ArrayList<Integer>();
  list.add(1);
  list.add(2);
  List<TeacherVo> teacherAndUser =  userMapper.getTeacherAndUserList(list);
  System.out.println(teacherAndUser.size());
}

代码示例来源:origin: stackoverflow.com

List<Integer> numbers = new ArrayList<Integer>(
   Arrays.asList(5,3,1,2,9,5,0,7)
 );
 List<Integer> head = numbers.subList(0, 4);
 List<Integer> tail = numbers.subList(4, 8);
 System.out.println(head); // prints "[5, 3, 1, 2]"
 System.out.println(tail); // prints "[9, 5, 0, 7]"
 Collections.sort(head);
 System.out.println(numbers); // prints "[1, 2, 3, 5, 9, 5, 0, 7]"
 tail.add(-1);
 System.out.println(numbers); // prints "[1, 2, 3, 5, 9, 5, 0, 7, -1]"

相关文章