code: private static boolean isFile(Node node) throws RepositoryException
     {
        if (!node.isNodeType("nt:file"))
        {
           return false;
        }
        if (!node.getNode("jcr:content").isNodeType("nt:resource"))
        {
           return false;
        }
        return true;
     }
docs: Check is node represents file.
  
  @param node
  the node.
  @return true if node represents file false otherwise.
  @throws RepositoryException
  in JCR errors occur.