Class StdIn

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int availableBytes
      Keeps track of number of bytes that are still available to read().
      private java.io.StringReader reader  
      private java.io.StringWriter writer  
    • Constructor Summary

      Constructors 
      Constructor Description
      StdIn​(java.lang.String[] lines)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int available()  
      java.lang.String[] capturedLines()  
      java.lang.String capturedString()  
      int read()  
      int read​(byte[] b, int off, int len)  
      • Methods inherited from class java.io.InputStream

        close, mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skip, transferTo
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • reader

        private final java.io.StringReader reader
      • writer

        private final java.io.StringWriter writer
      • availableBytes

        private int availableBytes
        Keeps track of number of bytes that are still available to read().
    • Constructor Detail

      • StdIn

        public StdIn​(java.lang.String[] lines)
    • Method Detail

      • available

        public int available()
                      throws java.io.IOException
        Overrides:
        available in class java.io.InputStream
        Throws:
        java.io.IOException
      • read

        public int read()
                 throws java.io.IOException
        Specified by:
        read in class java.io.InputStream
        Throws:
        java.io.IOException
      • read

        public int read​(byte[] b,
                        int off,
                        int len)
                 throws java.io.IOException
        Overrides:
        read in class java.io.InputStream
        Throws:
        java.io.IOException
      • capturedString

        public java.lang.String capturedString()
        Returns:
        the string that was read from System.in; note that buffering readers may read all lines eagerly
      • capturedLines

        public java.lang.String[] capturedLines()
        Returns:
        the lines that were read from System.in; note that buffering readers may read all lines eagerly