Unable to update the content of file content
public void createFile() {
try {
// Add the text file node
Node fileNode = projectNode.addNode("hello.txt", "nt:file");
Node contentNode = fileNode.addNode("jcr:content", "nt:resource");
// Set the jcr:data property with the file content
contentNode.setProperty("jcr:data", "hello world 1");
// Save the session to persist changes
session.save();
} catch (RepositoryException e) {
e.printStackTrace();
} finally {
if (resolver.isLive()) {
resolver.close();
}
}
}
I also tried to remove and set the content as below but it is not working,
if (fileNode.hasNode("jcr:content")) {
fileNode.getNode("jcr:content").remove();
}
Node contentNode = fileNode.addNode("jcr:content", "nt:resource");
Is there any way to handle this case? But still it is not working.