Class IOUtil

java.lang.Object
org.cy3sbml.util.IOUtil

public class IOUtil extends Object
Helper functions for input and output.
  • Constructor Details

    • IOUtil

      public IOUtil()
  • Method Details

    • readResource

      public static InputStream readResource(String resource)
      The classpath resource of the app.
      Parameters:
      resource - the absolute resource path
      Returns:
      the stream, null if there is no such resource
    • string2InputStream

      public static InputStream string2InputStream(String s)
      The UTF-8 bytes of the string as stream.
      Parameters:
      s - the string
      Returns:
      the stream
    • copyInputStream

      public static InputStream copyInputStream(InputStream is) throws IOException
      Reads the stream into memory and closes it, e.g. to read a stream twice.
      Parameters:
      is - the stream, closed afterwards
      Returns:
      a stream of the bytes read
      Throws:
      IOException - if the stream cannot be read
    • createUniqueFile

      public static File createUniqueFile(File directory, String fileName, String extension)
      A file in the directory with the name and extension that does not exist yet: the name with a suffix _0, _1, ... if the file exists.
      Parameters:
      directory - the directory
      fileName - the file name without extension
      extension - the file extension, with the dot
      Returns:
      the file, not created