{
return new String(bytes, encoding);
}
catch (UnsupportedEncodingException e)
{
throw new TransformerException(this, e);
}
}
}
else if (src instanceof InputStream)
{
try
{
PushbackInputStream pushbackStream = new PushbackInputStream((InputStream)src);
int firstByte = pushbackStream.read();
pushbackStream.unread((byte)firstByte);
if (this.checkStreamHeader((byte)firstByte))
{
return super.doTransform(pushbackStream, encoding);
}
else
{
try
{
return IOUtils.toString(pushbackStream, encoding);
}
finally
{
// this also closes the underlying stream that's stored in src
pushbackStream.close();
}
}
}
catch (IOException iox)
{
throw new TransformerException(this, iox);
}
}
else
{
throw new TransformerException(CoreMessages.transformOnObjectUnsupportedTypeOfEndpoint(
this.getName(), src.getClass(), endpoint));
}
}