Class IOUtils

java.lang.Object
org.eclipse.lemminx.utils.IOUtils

public class IOUtils extends Object
IO utilities class
Author:
Angelo ZERR
  • Constructor Details

    • IOUtils

      public IOUtils()
  • Method Details

    • convertStreamToString

      public static String convertStreamToString(InputStream is)
      Convert the given InputStream into a String. The source InputStream will then be closed.
      Parameters:
      is - the input stream
      Returns:
      the given input stream in a String.
    • detectXmlEncoding

      public static Charset detectXmlEncoding(byte[] bytes)
      Detect the encoding declared in the XML prolog of the given bytes.

      Scans only the first 200 bytes char-by-char for the encoding="..." attribute in <?xml ...?>. Returns UTF-8 if no prolog, no encoding attribute, or an unsupported encoding name is found.

      Parameters:
      bytes - the raw bytes of an XML document.
      Returns:
      the detected Charset, never null.