}
String filePrefix = new File(outputDir, dataPrefix).getPath();
try {
PhoneMetadataCollection metadataCollection =
BuildMetadataFromXml.buildPhoneMetadataCollection(inputFile, liteBuild);
for (PhoneMetadata metadata : metadataCollection.getMetadataList()) {
String regionCode = metadata.getId();
// For non-geographical country calling codes (e.g. +800), or for alternate formats, use the
// country calling codes instead of the region code to form the file name.
if (regionCode.equals("001") || regionCode.isEmpty()) {
regionCode = Integer.toString(metadata.getCountryCode());
}
PhoneMetadataCollection outMetadataCollection = new PhoneMetadataCollection();
outMetadataCollection.addMetadata(metadata);
FileOutputStream outputForRegion = new FileOutputStream(filePrefix + "_" + regionCode);
ObjectOutputStream out = new ObjectOutputStream(outputForRegion);
outMetadataCollection.writeExternal(out);
out.close();
}
Map<Integer, List<String>> countryCodeToRegionCodeMap =
BuildMetadataFromXml.buildCountryCodeToRegionCodeMap(metadataCollection);