Search code examples
javainputstreamtostring

JAVA InputStream.toString() back to InputStream


I am playing with an an old and abandoned JAVA renderer called Sunflow. In some of its classes one of methods saves image InputStream as string (InputStream.toString()). Now I wonder: is there a way how to convert back that saved InputStream.toString() value to InputStream?


Solution

  • No, InputStream does not override toString(), it uses the existing base implementation from Object, which returns:

    getClass().getName() + "@" + Integer.toHexString(hashCode())
    

    The result of this method call is something like: InputStream@<hex_hash_code>, and you can not recover the original InputStream from this String.