summaryrefslogtreecommitdiff
path: root/scripting/java/org/openoffice/netbeans/modules/office/utils/PackageRemover.java
diff options
context:
space:
mode:
Diffstat (limited to 'scripting/java/org/openoffice/netbeans/modules/office/utils/PackageRemover.java')
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/utils/PackageRemover.java17
1 files changed, 9 insertions, 8 deletions
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/utils/PackageRemover.java b/scripting/java/org/openoffice/netbeans/modules/office/utils/PackageRemover.java
index 270b30fde9d9..f79368f6f495 100644
--- a/scripting/java/org/openoffice/netbeans/modules/office/utils/PackageRemover.java
+++ b/scripting/java/org/openoffice/netbeans/modules/office/utils/PackageRemover.java
@@ -39,24 +39,25 @@ public class PackageRemover {
try {
String line;
+
while ((line = in.readLine()) != null) {
if (line.startsWith("package")) {
String newDeclaration = evaluate(line);
+
if (newDeclaration != null) {
out.write(newDeclaration, 0, newDeclaration.length());
out.newLine();
}
- }
- else {
+ } else {
out.write(line, 0, line.length());
out.newLine();
}
}
- }
- finally {
+ } finally {
if (in != null) {
in.close();
}
+
if (out != null) {
out.close();
}
@@ -65,8 +66,7 @@ public class PackageRemover {
if (!source.delete()) {
tmp.delete();
throw new IOException("Could not overwrite " + source);
- }
- else {
+ } else {
tmp.renameTo(source);
}
}
@@ -74,10 +74,12 @@ public class PackageRemover {
public static String evaluate(String line) {
int idx = line.indexOf(ParcelZipper.CONTENTS_DIRNAME);
+
if (idx == -1)
return line;
idx = idx + ParcelZipper.CONTENTS_DIRNAME.length();
+
if (line.charAt(idx) == '.')
return "package " + line.substring(idx + 1);;
@@ -89,8 +91,7 @@ public class PackageRemover {
try {
removeDeclaration(source);
- }
- catch (IOException ioe) {
+ } catch (IOException ioe) {
ioe.printStackTrace();
}
}