String s2 = getName((ResourceImpl) r2);
return s1.compareTo(s2);
}
});
Tag tag = doIndex(sorted);
if (repositoryFileName != null) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
PrintWriter pw = new PrintWriter(new OutputStreamWriter(out,
"UTF-8"));
pw.println("<?xml version='1.0' encoding='utf-8'?>");
pw
.println("<?xml-stylesheet type='text/xsl' href='http://www2.osgi.org/www/obr2html.xsl'?>");
tag.print(0, pw);
pw.close();
byte buffer[] = out.toByteArray();
String name = "repository.xml";
FileOutputStream fout = new FileOutputStream(repositoryFileName);
if (repositoryFileName.endsWith(".zip")) {
ZipOutputStream zip = new ZipOutputStream(fout);
CRC32 checksum = new CRC32();
checksum.update(buffer);
ZipEntry ze = new ZipEntry(name);
ze.setSize(buffer.length);
ze.setCrc(checksum.getValue());
zip.putNextEntry(ze);
zip.write(buffer, 0, buffer.length);
zip.closeEntry();
zip.close();
}
else {
fout.write(buffer);
}
fout.close();
}
if (!quiet) {
PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
pw.println("<?xml version='1.0' encoding='utf-8'?>");
pw
.println("<?xml-stylesheet type='text/xsl' href='http://www2.osgi.org/www/obr2html.xsl'?>");
tag.print(0, pw);
pw.close();
}
}