Example usage for java.io PrintStream println

List of usage examples for java.io PrintStream println

Introduction

In this page you can find the example usage for java.io PrintStream println.

Prototype

public void println(Object x) 

Source Link

Document

Prints an Object and then terminate the line.

Usage

From source file:com.globalsight.ling.tm3.tools.DeleteTmCommand.java

@Override
protected void printExtraHelp(PrintStream out) {
    out.println("Deletes a TM, including all TM data.");
    out.println("Use with caution -- this is irreversible!");
}

From source file:Main.java

public void run() {
    try {//from ww w .j  ava  2s .  c  o  m
        PrintStream pstream = new PrintStream(csocket.getOutputStream());
        for (int i = 10; i >= 0; i--) {
            pstream.println(i);
        }
        pstream.close();
        csocket.close();
    } catch (IOException e) {
        System.out.println(e);
    }
}

From source file:MultiThreadServer.java

public void run() {
    try {/*from w ww  .  j av  a2s .c  om*/
        PrintStream pstream = new PrintStream(csocket.getOutputStream());
        for (int i = 100; i >= 0; i--) {
            pstream.println(i + " bottles of beer on the wall");
        }
        pstream.close();
        csocket.close();
    } catch (IOException e) {
        System.out.println(e);
    }
}

From source file:com.ibm.devops.dra.AbstractDevOpsAction.java

public static void printPluginVersion(ClassLoader loader, PrintStream printStream) {
    final Properties properties = new Properties();
    try {/*  w  ww.j av  a  2s .  c  om*/
        properties.load(loader.getResourceAsStream("plugin.properties"));
        printStream.println("[IBM Cloud DevOps] version: " + properties.getProperty("version"));
    } catch (IOException e) {
        e.printStackTrace();
    }

}

From source file:de.huxhorn.lilith.Lilith.java

public static void startUI(final String appTitle) {
    final Logger logger = LoggerFactory.getLogger(Lilith.class);

    UIManager.installLookAndFeel("JGoodies Windows", "com.jgoodies.looks.windows.WindowsLookAndFeel");
    UIManager.installLookAndFeel("JGoodies Plastic", "com.jgoodies.looks.plastic.PlasticLookAndFeel");
    UIManager.installLookAndFeel("JGoodies Plastic 3D", "com.jgoodies.looks.plastic.Plastic3DLookAndFeel");
    UIManager.installLookAndFeel("JGoodies Plastic XP", "com.jgoodies.looks.plastic.PlasticXPLookAndFeel");
    // Substance requires 1.6
    UIManager.installLookAndFeel("Substance Dark - Twilight",
            "org.pushingpixels.substance.api.skin.SubstanceTwilightLookAndFeel");
    UIManager.installLookAndFeel("Substance Light - Business",
            "org.pushingpixels.substance.api.skin.SubstanceBusinessLookAndFeel");

    //UIManager.installLookAndFeel("Napkin", "net.sourceforge.napkinlaf.NapkinLookAndFeel");

    // look & feels must be installed before creation of ApplicationPreferences.
    ApplicationPreferences applicationPreferences = new ApplicationPreferences();

    // init look & feel
    String lookAndFeelName = applicationPreferences.getLookAndFeel();
    String systemLookAndFeelClassName = UIManager.getSystemLookAndFeelClassName();
    String lookAndFeelClassName = systemLookAndFeelClassName;
    if (lookAndFeelName != null) {
        for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
            if (lookAndFeelName.equals(info.getName())) {
                lookAndFeelClassName = info.getClassName();
                break;
            }/*from  w ww  .j a va2 s  .  c  o  m*/
        }
    }

    try {
        UIManager.setLookAndFeel(lookAndFeelClassName);
    } catch (Throwable e) {
        if (logger.isWarnEnabled())
            logger.warn("Failed to set look&feel to '{}'.", lookAndFeelClassName, e);
        if (!lookAndFeelClassName.equals(systemLookAndFeelClassName)) {
            try {
                UIManager.setLookAndFeel(systemLookAndFeelClassName);
                lookAndFeelClassName = systemLookAndFeelClassName;
            } catch (Throwable e2) {
                if (logger.isWarnEnabled())
                    logger.warn("Failed to set look&feel to '{}'.", systemLookAndFeelClassName, e);
                lookAndFeelClassName = null;
            }
        }
    }

    boolean screenMenuBar = false;
    if (systemLookAndFeelClassName.equals(lookAndFeelClassName)) {
        // This instance of application is only used to query some info. The real one is in MainFrame.
        Application application = new DefaultApplication();

        if (application.isMac()) {
            // Use Apple Aqua L&F screen menu bar if available; set property before any frames created
            try {
                System.setProperty(APPLE_SCREEN_MENU_BAR_SYSTEM_PROPERTY, "true");
                screenMenuBar = true;
            } catch (Throwable e) {
                try {
                    screenMenuBar = Boolean
                            .parseBoolean(System.getProperty(APPLE_SCREEN_MENU_BAR_SYSTEM_PROPERTY, "false"));
                } catch (Throwable e2) {
                    // ignore
                }
            }
        }
    }

    applicationPreferences.setUsingScreenMenuBar(screenMenuBar);

    boolean splashScreenDisabled = applicationPreferences.isSplashScreenDisabled();
    try {
        SplashScreen splashScreen = null;
        if (!splashScreenDisabled) {
            CreateSplashRunnable createRunnable = new CreateSplashRunnable(appTitle);
            EventQueue.invokeAndWait(createRunnable);
            splashScreen = createRunnable.getSplashScreen();
            Thread.sleep(500); // so the splash gets the chance to get displayed :(
            updateSplashStatus(splashScreen, "Initialized application preferences...");
        }

        File startupApplicationPath = applicationPreferences.getStartupApplicationPath();
        if (startupApplicationPath.mkdirs()) {
            if (logger.isDebugEnabled())
                logger.debug("Created '{}'.", startupApplicationPath.getAbsolutePath());
        }

        // System.err redirection
        {
            File errorLog = new File(startupApplicationPath, "errors.log");
            boolean freshFile = false;
            if (!errorLog.isFile()) {
                freshFile = true;
            }
            try {
                FileOutputStream fos = new FileOutputStream(errorLog, true);
                PrintStream ps = new PrintStream(fos, true, StandardCharsets.UTF_8.name());
                if (!freshFile) {
                    ps.println("----------------------------------------");
                }
                String currentDateTime = DateTimeFormatters.DATETIME_IN_SYSTEM_ZONE_SPACE.format(Instant.now());
                ps.println("Started " + APP_NAME + " V" + APP_VERSION + " at " + currentDateTime);
                System.setErr(ps);
                if (logger.isInfoEnabled())
                    logger.info("Writing System.err to '{}'.", errorLog.getAbsolutePath());
            } catch (FileNotFoundException | UnsupportedEncodingException e) {
                e.printStackTrace();
            }
        }

        File prevPathFile = new File(startupApplicationPath,
                ApplicationPreferences.PREVIOUS_APPLICATION_PATH_FILENAME);
        if (prevPathFile.isFile()) {
            updateSplashStatus(splashScreen, "Moving application path content...");
            moveApplicationPathContent(prevPathFile, startupApplicationPath);
        }
        if (!applicationPreferences.isLicensed()) {
            hideSplashScreen(splashScreen);

            LicenseAgreementDialog licenseDialog = new LicenseAgreementDialog();
            licenseDialog.setAlwaysOnTop(true);
            licenseDialog.setAutoRequestFocus(true);
            Windows.showWindow(licenseDialog, null, true);
            if (licenseDialog.isLicenseAgreed()) {
                applicationPreferences.setLicensed(true);
            } else {
                if (logger.isWarnEnabled())
                    logger.warn("Didn't accept license! Exiting...");
                System.exit(-1);
            }
        }

        updateSplashStatus(splashScreen, "Creating main window...");
        CreateMainFrameRunnable createMain = new CreateMainFrameRunnable(applicationPreferences, splashScreen,
                appTitle);
        EventQueue.invokeAndWait(createMain);
        final MainFrame frame = createMain.getMainFrame();
        if (logger.isDebugEnabled())
            logger.debug("After show...");
        updateSplashStatus(splashScreen, "Initializing application...");
        EventQueue.invokeAndWait(frame::startUp);
        hideSplashScreen(splashScreen);
        mainFrame = frame;

    } catch (InterruptedException ex) {
        if (logger.isInfoEnabled())
            logger.info("Interrupted...", ex);
        IOUtilities.interruptIfNecessary(ex);
    } catch (InvocationTargetException ex) {
        if (logger.isWarnEnabled())
            logger.warn("InvocationTargetException...", ex);
        if (logger.isWarnEnabled())
            logger.warn("Target-Exception: ", ex.getTargetException());

    }
}

From source file:com.globalsight.ling.tm3.tools.ShowTmCommand.java

@Override
protected void printExtraHelp(PrintStream out) {
    out.println("Displays all TM3 TMs.");
}

From source file:com.globalsight.ling.tm3.integration.EnableTm3Command.java

@Override
protected void printExtraHelp(PrintStream out) {
    out.println("Enable the tm3 storage engine for a given company.");
    out.println("This does two things: create storage tables in the DB for");
    out.println("the company, and modify the TM_VERSION column for the");
    out.println("company in the COMPANY table.  Running this command");
    out.println("multiple times for a single company will have no effect.");
}

From source file:com.blackducksoftware.integration.hub.detect.help.print.HelpTextWriter.java

public void write(final PrintStream printStream) {
    printStream.println(String.join(System.lineSeparator(), pieces));
}

From source file:edu.northwestern.bioinformatics.studycalendar.osgi.commands.SystemPropertyCommand.java

private void printProperty(PrintStream out, String name, String value) {
    out.println(String.format("%s=\"%s\"", name, StringEscapeUtils.escapeJava(value)));
}

From source file:net.extemporal.test.Main.java

@Command
public void localTest(String m1, String m2) {
    SimpleTestPlatform hakuna = new SimpleTestPlatform("Hakuna"), matata = new SimpleTestPlatform("Matata");

    PrintStream w = System.out;

    w.println("Local test commencing");
    if (m1 != null && m1.trim().length() > 0) {
        w.println("Hakuna sending message '" + m1 + "' to Matata");

        hakuna.sendMessage("Matata", m1);
        w.flush();/*from   w  w  w.  j ava  2 s  .c om*/
    }

    if (m2 != null && m2.trim().length() > 0) {
        w.println("Matata sending message '" + m2 + "' to Hakuna");
        matata.sendMessage("Hakuna", m2);
        w.flush();
    }

    hakuna.shutdown();
    matata.shutdown();
    w.println("Local test ended!");
}