src/java.base/share/classes/java/io/Console.java

Print this page




 547 
 548             public Charset charset() {
 549                 // This method is called in sun.security.util.Password,
 550                 // cons already exists when this method is called
 551                 return cons.cs;
 552             }
 553         });
 554     }
 555     private static Console cons;
 556     private native static boolean istty();
 557     private Console() {
 558         readLock = new Object();
 559         writeLock = new Object();
 560         String csname = encoding();
 561         if (csname != null) {
 562             try {
 563                 cs = Charset.forName(csname);
 564             } catch (Exception x) {}
 565         }
 566         if (cs == null)
 567             cs = Charset.defaultCharset();
 568         out = StreamEncoder.forOutputStreamWriter(
 569                   new FileOutputStream(FileDescriptor.out),
 570                   writeLock,
 571                   cs);
 572         pw = new PrintWriter(out, true) { public void close() {} };
 573         formatter = new Formatter(out);
 574         reader = new LineReader(StreamDecoder.forInputStreamReader(
 575                      new FileInputStream(FileDescriptor.in),
 576                      readLock,
 577                      cs));
 578         rcb = new char[1024];
 579     }
 580 }


 547 
 548             public Charset charset() {
 549                 // This method is called in sun.security.util.Password,
 550                 // cons already exists when this method is called
 551                 return cons.cs;
 552             }
 553         });
 554     }
 555     private static Console cons;
 556     private native static boolean istty();
 557     private Console() {
 558         readLock = new Object();
 559         writeLock = new Object();
 560         String csname = encoding();
 561         if (csname != null) {
 562             try {
 563                 cs = Charset.forName(csname);
 564             } catch (Exception x) {}
 565         }
 566         if (cs == null)
 567             cs = Boolean.getBoolean("windows.UnicodeConsole") ? Charset.defaultUnicodeCharset() : Charset.defaultCharset();
 568         out = StreamEncoder.forOutputStreamWriter(
 569                   new FileOutputStream(FileDescriptor.out),
 570                   writeLock,
 571                   cs);
 572         pw = new PrintWriter(out, true) { public void close() {} };
 573         formatter = new Formatter(out);
 574         reader = new LineReader(StreamDecoder.forInputStreamReader(
 575                      new FileInputStream(FileDescriptor.in),
 576                      readLock,
 577                      cs));
 578         rcb = new char[1024];
 579     }
 580 }