Java Error Print printErrorln(String string)

Here you can find the source of printErrorln(String string)

Description

print Errorln

License

Apache License

Declaration

public static void printErrorln(String string) 

Method Source Code

//package com.java2s;
/**//from  ww  w  . j  av  a 2  s .c  om
 * Copyright Notice
 *
 * This is a work of the U.S. Government and is not subject to copyright
 * protection in the United States. Foreign copyrights may apply.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

public class Main {
    private static boolean progressLine = false;
    private static int printsSinceReturn = 0;
    private static boolean progressLineUsed = false;
    private static StringBuilder consoleOutputCache = new StringBuilder();
    private static String eol = System.getProperty("line.separator");
    public static boolean disableFancy = (System.console() == null);

    public static void printErrorln(String string) {
        if (progressLine) {
            if (disableFancy) {
                if (progressLineUsed) {
                    System.out.println();
                    printsSinceReturn = 0;
                }
            } else {
                System.out.print("\r \r");
            }
            progressLine = false;
        }
        System.err.println(string);
        consoleOutputCache.append("ERROR->");
        consoleOutputCache.append(string);
        consoleOutputCache.append(eol);
        printsSinceReturn = 0;
        progressLine = true;
        progressLineUsed = false;
    }

    public static void println(String string) {
        if (progressLine) {
            if (disableFancy) {
                if (progressLineUsed) {
                    System.out.println();
                    printsSinceReturn = 0;
                }
            } else {
                System.out.print("\r \r");
            }
        }
        System.out.println(string);
        consoleOutputCache.append(string);
        consoleOutputCache.append(eol);
        progressLine = true;
        progressLineUsed = false;
    }

    public static void print(String string) {
        if (progressLine) {
            if (disableFancy) {
                if (progressLineUsed) {
                    System.out.println();
                    printsSinceReturn = 0;
                }
            } else {
                System.out.print("\r \r");
            }
            progressLine = false;
        }
        System.out.print(string);
        consoleOutputCache.append(string);
    }
}

Related

  1. printError(String s)
  2. printErrorAndExit(String message)
  3. printErrorFooter(String content)
  4. printErrorInfo(Object e)
  5. printErrorLine()
  6. printErrorMessage(final String prg_name, final String message)
  7. printErrorMessage(String errorMessage)
  8. printErrorMsgTraceAsCause(Throwable throwable, StackTraceElement[] causedTrace)