diff --git a/java/resources/com/google/i18n/phonenumbers/GenerateAreaCodeData.java b/java/resources/com/google/i18n/phonenumbers/GenerateAreaCodeData.java index b424cb547..8123df17e 100644 --- a/java/resources/com/google/i18n/phonenumbers/GenerateAreaCodeData.java +++ b/java/resources/com/google/i18n/phonenumbers/GenerateAreaCodeData.java @@ -35,10 +35,6 @@ import java.util.List; import java.util.Set; import java.util.SortedMap; import java.util.TreeMap; -import java.util.jar.Attributes; -import java.util.jar.JarEntry; -import java.util.jar.JarOutputStream; -import java.util.jar.Manifest; import java.util.logging.Level; import java.util.logging.Logger; @@ -49,67 +45,37 @@ import java.util.logging.Logger; * *
The text files must be located in sub-directories of the provided input path. For each input
* file inputPath/lang/countryCallingCode.txt the corresponding binary file is generated as
- * outputPath/countryCallingCode_lang. The binary files are stored into the resulting JAR.
+ * outputPath/countryCallingCode_lang.
*
* @author Philippe Liard
*/
public class GenerateAreaCodeData {
// The path to the input directory containing the languages directories.
private final File inputPath;
- // The path to the output JAR file.
- private final File outputJarPath;
+ // The path to the output directory.
+ private final File outputPath;
// Whether the data is generated for testing.
private final boolean forTesting;
private static final Logger LOGGER = Logger.getLogger(GenerateAreaCodeData.class.getName());
- private JarOutputStream createJar() throws FileNotFoundException, IOException {
- Manifest manifest = new java.util.jar.Manifest();
- manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
- JarOutputStream target = new JarOutputStream(new FileOutputStream(outputJarPath));
- return target;
- }
-
- private void addFileToJar(File file, JarOutputStream jar) throws IOException {
- JarEntry entry = new JarEntry(
- GenerateAreaCodeData.class.getPackage().getName().replace('.', '/') +
- (forTesting ? "/geocoding_testing_data/" : "/geocoding_data/") +
- file.getPath());
- entry.setTime(file.lastModified());
- jar.putNextEntry(entry);
- BufferedInputStream bufferedInputStream = null;
-
- try {
- bufferedInputStream = new BufferedInputStream(new FileInputStream(file));
- byte[] buffer = new byte[4096];
-
- for (int read = 0; (read = bufferedInputStream.read(buffer)) > 0; ) {
- jar.write(buffer, 0, read);
- }
- } finally {
- jar.closeEntry();
- closeFile(bufferedInputStream);
- }
- }
-
- public GenerateAreaCodeData(File inputPath, File outputJarPath, boolean forTesting)
+ public GenerateAreaCodeData(File inputPath, File outputPath, boolean forTesting)
throws IOException {
if (!inputPath.isDirectory()) {
throw new IOException("The provided input path does not exist: " +
inputPath.getAbsolutePath());
}
- File parentDirectory = outputJarPath.getParentFile();
- if (parentDirectory.exists()) {
- if (!parentDirectory.isDirectory()) {
- throw new IOException("Expected directory: " + parentDirectory.getAbsolutePath());
+ if (outputPath.exists()) {
+ if (!outputPath.isDirectory()) {
+ throw new IOException("Expected directory: " + outputPath.getAbsolutePath());
}
} else {
- if (!parentDirectory.mkdirs()) {
- throw new IOException("Could not create directory " + parentDirectory.getAbsolutePath());
+ if (!outputPath.mkdirs()) {
+ throw new IOException("Could not create directory " + outputPath.getAbsolutePath());
}
}
this.inputPath = inputPath;
- this.outputJarPath = outputJarPath;
+ this.outputPath = outputPath;
this.forTesting = forTesting;
}
@@ -207,7 +173,8 @@ public class GenerateAreaCodeData {
}
mappings.add(new Pair