Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/401.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用WebItemApGenerator生成html文件_Java_Sitemap - Fatal编程技术网

Java 使用WebItemApGenerator生成html文件

Java 使用WebItemApGenerator生成html文件,java,sitemap,Java,Sitemap,无法使用sitemapgen库生成许多sitemap xml文件,出现以下错误 公共类站点地图{ 公共静态整数计数=0 public static void main(String[] args) throws IOException { WebSitemapGenerator webSitemapGenerator = WebSitemapGenerator.builder("http://34.224.89.46", new File("/home/arivu/Desktop/SEO

无法使用sitemapgen库生成许多sitemap xml文件,出现以下错误

公共类站点地图{ 公共静态整数计数=0

public static void main(String[] args) throws IOException {
    WebSitemapGenerator webSitemapGenerator = WebSitemapGenerator.builder("http://34.224.89.46", new File("/home/arivu/Desktop/SEO")).gzip(true).build();
    try {
        File parentDirectory = new File("/var/www/html/tech-jobs");
        parentDirectory.listFiles(new FilenameFilter() {

            @Override
            public boolean accept(File dir, String name) {
                String directory = name;
                String childDirectory = new StringBuilder(dir.toString()).append("/").append(name).toString();
                File newFile = new File(childDirectory);
                newFile.listFiles(new FilenameFilter() {
                    public boolean accept(File dir, String fileName) {
                        System.out.println(count++);
                        String location = "http://34.224.89.46/tech-jobs" + "/" + directory + "/" + fileName;
                        WebSitemapUrl webSitemapUrli;
                        try {
                            webSitemapUrli = new WebSitemapUrl.Options(location).lastMod(new Date()).priority(1.0).changeFreq(ChangeFreq.HOURLY).build();
                            webSitemapGenerator.addUrl(webSitemapUrli);
                        } catch (MalformedURLException e) {
                            e.printStackTrace();
                        }
                        if(count == 20) {
                            webSitemapGenerator.write();
                            webSitemapGenerator.writeSitemapsWithIndex();
                        }
                        return fileName != null;
                    }
                });
                return name != null;
            }
        });

    } catch (Exception e) {
        e.printStackTrace();
    }

}

}

任何人的帮助请提供您的代码。上面的代码是我的代码当我运行这个java文件时,我得到以下异常java.lang.RuntimeException:没有添加URL,站点地图索引将为空;您必须使用addURL添加一些URL