Tabnine Logo
System.console
Code IndexAdd Tabnine to your IDE (free)

How to use
console
method
in
java.lang.System

Best Java code snippets using java.lang.System.console (Showing top 20 results out of 3,060)

origin: vipshop/vjtools

public InteractiveTask(VJTop app) {
  this.app = app;
  tty = System.err;
  console = System.console();
}
origin: syncany/syncany

private InitConsole() {
  this.console = System.console();
  this.systemIn = null;
  this.systemOut = null;
}
origin: jenkinsci/jenkins

public String call() throws IOException {
  Console console = System.console();
  if (console == null)    return null;    // no terminal
  char[] w = console.readPassword("Password:");
  if (w==null)    return null;
  return new String(w);
}
origin: jenkinsci/jenkins

private static String askForPasswd(String filePath){
  Console cons = System.console();
  String passwd = null;
  if (cons != null){
    char[] p = cons.readPassword("%s", "Enter passphrase for " + filePath + ":");
    passwd = String.valueOf(p);
  }
  return passwd;
}
origin: neo4j/neo4j

@Override
public char[] promptPassword( String fmt, Object... args )
{
  return System.console().readPassword( fmt, args );
}
origin: neo4j/neo4j

@Override
public String readLine()
{
  return System.console().readLine();
}
origin: neo4j/neo4j

@Override
public String promptLine( String fmt, Object... args )
{
  return System.console().readLine( fmt, args );
}
origin: stackoverflow.com

 System.out.print("Enter something:");
String input = System.console().readLine();
origin: stackoverflow.com

 import java.io.Console;
Console console = System.console();
String s = console.readLine();
int i = Integer.parseInt(console.readLine());
origin: apache/ignite

/** Constructor. */
private GridConsoleAdapter(Console delegate) {
  this.delegate = System.console();
  if (delegate == null)
    throw new NullPointerException("Console is not available.");
}
origin: org.apache.hadoop/hadoop-common

public char[] readPassword(String prompt) {
 Console console = System.console();
 char[] pass = console.readPassword(prompt);
 return pass;
}
origin: prestodb/presto

private String getPassword()
{
  checkState(clientOptions.user != null, "Username must be specified along with password");
  String defaultPassword = System.getenv("PRESTO_PASSWORD");
  if (defaultPassword != null) {
    return defaultPassword;
  }
  java.io.Console console = System.console();
  if (console == null) {
    throw new RuntimeException("No console from which to read password");
  }
  char[] password = console.readPassword("Password: ");
  if (password != null) {
    return new String(password);
  }
  return "";
}
origin: floragunncom/search-guard

private static String promptForPassword(String passwordName, String commandLineOption, String envVarName) throws Exception {
  final Console console = System.console();
  if(console == null) {
    throw new Exception("Cannot allocate a console. Set env var "+envVarName+" or "+commandLineOption+" on commandline in that case");
  }
  return new String(console.readPassword("[%s]", passwordName+" password:"));
}

origin: apache/incubator-gobblin

 private static String getPasswordFromConsole() {
  System.out.print("Please enter the keystore password: ");
  return new String(System.console().readPassword());
 }
}
origin: stackoverflow.com

 public class ConsoleDemo {
 public static void main(String[] args) {
  String[] data = { "\u250C\u2500\u2500\u2500\u2500\u2500\u2510", 
    "\u2502Hello\u2502",
    "\u2514\u2500\u2500\u2500\u2500\u2500\u2518" };
  for (String s : data) {
   System.out.println(s);
  }
  for (String s : data) {
   System.console().writer().println(s);
  }
 }
}
origin: apache/ignite

/** */
public static @Nullable GridConsoleAdapter getInstance() {
  Console console = System.console();
  return console == null ? null : new GridConsoleAdapter(console);
}
origin: confluentinc/ksql

private void showWelcomeMessage() {
 final Console console = System.console();
 if (console == null) {
  return;
 }
 final PrintWriter writer =
   new PrintWriter(new OutputStreamWriter(System.out, StandardCharsets.UTF_8));
 WelcomeMsgUtils.displayWelcomeMessage(80, writer);
 writer.printf("Server %s started with query file %s. Interactive mode is disabled.%n",
        Version.getVersion(),
        queriesFile);
 writer.flush();
}
origin: neo4j/neo4j

private DiagnosticsReporterProgress buildProgress()
{
  DiagnosticsReporterProgress progress;
  if ( System.console() != null )
  {
    progress = new InteractiveProgress( out, verbose );
  }
  else
  {
    progress = new NonInteractiveProgress( out, verbose );
  }
  return progress;
}
origin: org.apache.logging.log4j/log4j-api

@Test
public void testGetMappedProperty_sun_stdout_encoding() {
  final PropertiesUtil pu = new PropertiesUtil(System.getProperties());
  Charset expected = System.console() == null ? Charset.defaultCharset() : StandardCharsets.UTF_8;
  assertEquals(expected, pu.getCharsetProperty("sun.stdout.encoding"));
}
origin: org.apache.logging.log4j/log4j-api

@Test
public void testGetMappedProperty_sun_stderr_encoding() {
  final PropertiesUtil pu = new PropertiesUtil(System.getProperties());
  Charset expected = System.console() == null ? Charset.defaultCharset() : StandardCharsets.UTF_8;
  assertEquals(expected, pu.getCharsetProperty("sun.err.encoding"));
}
java.langSystemconsole

Javadoc

Returns the java.io.Console associated with this VM, or null. Not all VMs will have an associated console. A console is typically only available for programs run from the command line.

Popular methods of System

  • currentTimeMillis
    Returns the current time in milliseconds. Note that while the unit of time of the return value is a
  • getProperty
    Returns the value of a particular system property. The defaultValue will be returned if no such prop
  • arraycopy
  • exit
  • setProperty
    Sets the value of a particular system property.
  • nanoTime
    Returns the current timestamp of the most precise timer available on the local system, in nanosecond
  • getenv
    Returns the value of the environment variable with the given name, or null if no such variable exist
  • getProperties
    Returns the system properties. Note that this is not a copy, so that changes made to the returned Pr
  • identityHashCode
    Returns an integer hash code for the parameter. The hash code returned is the same one that would be
  • getSecurityManager
    Gets the system security interface.
  • gc
    Indicates to the VM that it would be a good time to run the garbage collector. Note that this is a h
  • lineSeparator
    Returns the system's line separator. On Android, this is "\n". The value comes from the value of the
  • gc,
  • lineSeparator,
  • clearProperty,
  • setOut,
  • setErr,
  • loadLibrary,
  • load,
  • setSecurityManager,
  • mapLibraryName

Popular in Java

  • Making http requests using okhttp
  • setScale (BigDecimal)
  • getSupportFragmentManager (FragmentActivity)
  • runOnUiThread (Activity)
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • LinkedHashMap (java.util)
    LinkedHashMap is an implementation of Map that guarantees iteration order. All optional operations a
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • Pattern (java.util.regex)
    Patterns are compiled regular expressions. In many cases, convenience methods such as String#matches
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now