Class StringIO


  • public class StringIO
    extends java.lang.Object
    Utility class with static methods to read the entire contents of a file, URL, InputStream, or Reader into a single String that is returned to the user.
    Since:
    Java 3D 1.4
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String readFully​(java.io.File file)
      Read the entire contents of the specified file and return a single String object containing the contents of the file.
      static java.lang.String readFully​(java.io.InputStream stream)
      Read the entire contents of the specified InputStream and return a single String object containing the contents of the InputStream.
      static java.lang.String readFully​(java.io.Reader reader)
      Read the entire contents of the specified Reader and return a single String object containing the contents of the InputStream.
      static java.lang.String readFully​(java.lang.String fileName)
      Read the entire contents of the specified file and return a single String object containing the contents of the file.
      static java.lang.String readFully​(java.net.URL url)
      Read the entire contents of the specified URL and return a single String object containing the contents of the URL.
      • Methods inherited from class java.lang.Object

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

      • readFully

        public static java.lang.String readFully​(java.lang.String fileName)
                                          throws java.io.IOException
        Read the entire contents of the specified file and return a single String object containing the contents of the file.
        Parameters:
        fileName - the name of the file from which to read
        Returns:
        a String containing the contents of the input file
        Throws:
        java.io.IOException - if the specified file cannot be opened, or if an I/O error occurs while reading the file
      • readFully

        public static java.lang.String readFully​(java.io.File file)
                                          throws java.io.IOException
        Read the entire contents of the specified file and return a single String object containing the contents of the file. This method does not return until the end of the input file is reached.
        Parameters:
        file - a File from which to read
        Returns:
        a String containing the contents of the input file
        Throws:
        java.io.IOException - if the specified file cannot be opened, or if an I/O error occurs while reading the file
      • readFully

        public static java.lang.String readFully​(java.net.URL url)
                                          throws java.io.IOException
        Read the entire contents of the specified URL and return a single String object containing the contents of the URL. This method does not return until an end of stream is reached for the URL.
        Parameters:
        url - a URL from which to read
        Returns:
        a String containing the contents of the input URL
        Throws:
        java.io.IOException - if the specified URL cannot be opened, or if an I/O error occurs while reading the URL
      • readFully

        public static java.lang.String readFully​(java.io.InputStream stream)
                                          throws java.io.IOException
        Read the entire contents of the specified InputStream and return a single String object containing the contents of the InputStream. This method does not return until the end of the input stream is reached.
        Parameters:
        stream - an InputStream from which to read
        Returns:
        a String containing the contents of the input stream
        Throws:
        java.io.IOException - if an I/O error occurs while reading the input stream
      • readFully

        public static java.lang.String readFully​(java.io.Reader reader)
                                          throws java.io.IOException
        Read the entire contents of the specified Reader and return a single String object containing the contents of the InputStream. This method does not return until the end of the input file or stream is reached.
        Parameters:
        reader - a Reader from which to read
        Returns:
        a String containing the contents of the stream
        Throws:
        java.io.IOException - if an I/O error occurs while reading the input stream