@jhansi_123 I believe you have created custom component to render txt content - In that case please follow below steps.
- Create Sling Model
- Create OSGi Service
- Refer/ Call to that OSGi service through Sling Model
- Render that content in HTL with the help of Sling Model
Please refer below sample code which you may need to read txt from JCR.
File should have an nt:file node, which has a jcr:content node with jcr:data property.
You can read the xml from jcr:data i.e: jcrContent.getProperty("jcr:data").getBinary().getStream();/
InputStream is = jcrContent.getProperty("jcr:data").getBinary()
.getStream();
BufferedInputStream bis = new BufferedInputStream(is);
ByteArrayOutputStream buf = new ByteArrayOutputStream();
int resultNumber = bis.read();
while (resultNumber != -1) {
byte b = (byte) resultNumber;
buf.write(b);
resultNumber = bis.read();
}