jaulib v1.3.0
Jau Support Library (C++, Java, ..)
PrintUtil.java
Go to the documentation of this file.
1/**
2 * Author: Sven Gothel <sgothel@jausoft.com>
3 * Copyright (c) 2022 Gothel Software e.K.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sublicense, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24package org.jau.io;
25
26import java.io.PrintStream;
27
28import org.jau.sys.Clock;
29
30public class PrintUtil extends Clock {
31 /**
32 * Convenient {@link PrintStream#printf(String, Object...)} invocation, prepending the {@link #elapsedTimeMillis()} timestamp.
33 * @param out the output stream
34 * @param format the format
35 * @param args the arguments
36 */
37 public static void fprintf_td(final PrintStream out, final String format, final Object ... args) {
38 out.printf("[%,9d] ", elapsedTimeMillis());
39 out.printf(format, args);
40 }
41 /**
42 * Convenient {@link PrintStream#println(String)} invocation, prepending the {@link #elapsedTimeMillis()} timestamp.
43 * @param out the output stream
44 * @param msg the string message
45 */
46 public static void println(final PrintStream out, final String msg) {
47 out.printf("[%,9d] %s%s", elapsedTimeMillis(), msg, System.lineSeparator());
48 }
49 /**
50 * Convenient {@link PrintStream#print(String)} invocation, prepending the {@link #elapsedTimeMillis()} timestamp.
51 * @param out the output stream
52 * @param msg the string message
53 */
54 public static void print(final PrintStream out, final String msg) {
55 out.printf("[%,9d] %s", elapsedTimeMillis(), msg);
56 }
57
58}
static void print(final PrintStream out, final String msg)
Convenient PrintStream#print(String) invocation, prepending the elapsedTimeMillis() timestamp.
Definition: PrintUtil.java:54
static void fprintf_td(final PrintStream out, final String format, final Object ... args)
Convenient PrintStream#printf(String, Object...) invocation, prepending the elapsedTimeMillis() times...
Definition: PrintUtil.java:37
static void println(final PrintStream out, final String msg)
Convenient PrintStream#println(String) invocation, prepending the elapsedTimeMillis() timestamp.
Definition: PrintUtil.java:46
static long elapsedTimeMillis()
Returns current elapsed monotonic time in milliseconds since module startup, see startupTimeMillis().
Definition: Clock.java:88