Package org.eclipse.lemminx.utils
Class IOUtils
java.lang.Object
org.eclipse.lemminx.utils.IOUtils
IO utilities class
- Author:
- Angelo ZERR
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringConvert the givenInputStreaminto a String.static CharsetdetectXmlEncoding(byte[] bytes) Detect the encoding declared in the XML prolog of the given bytes.
-
Constructor Details
-
IOUtils
public IOUtils()
-
-
Method Details
-
convertStreamToString
Convert the givenInputStreaminto a String. The source InputStream will then be closed.- Parameters:
is- the input stream- Returns:
- the given input stream in a String.
-
detectXmlEncoding
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.
-