InputStream strm = getDataStream(problems);
if (strm == null)
return "";
Reader reader = null;
BOMInputStream bomStream = null;
StringBuilder str = new StringBuilder();
try
{
bomStream = new BOMInputStream(strm);
String bomCharsetName = bomStream.getBOMCharsetName();
if (bomCharsetName == null)
{
if (encoding == null || encoding.length() == 0)
{
bomCharsetName = System.getProperty("file.encoding");
}
else
{
bomCharsetName = encoding;
}
}
reader = new InputStreamReader(bomStream, bomCharsetName);
char[] line = new char[2048];
int count = 0;
while ((count = reader.read(line, 0, line.length)) >= 0)
{
str.append(line, 0, count);
}
}
catch (IOException e)
{
problems.add(new EmbedSourceAttributeCouldNotBeReadProblem(source));
}
finally
{
if (bomStream != null)
{
try
{
bomStream.close();
}
catch (IOException e)
{
}
}