@@ -134,16 +134,16 @@ public class DirectoryIterator implements ClassFileIterator { | |||||
= new FileInputStream(element); | = new FileInputStream(element); | ||||
try { | try { | ||||
if (element.getName().endsWith(".class")) { | |||||
if (element.getName().endsWith(".class")) { | |||||
// create a data input stream from the jar | |||||
// input stream | |||||
ClassFile javaClass = new ClassFile(); | |||||
// create a data input stream from the jar | |||||
// input stream | |||||
ClassFile javaClass = new ClassFile(); | |||||
javaClass.read(inFileStream); | |||||
javaClass.read(inFileStream); | |||||
nextElement = javaClass; | |||||
} | |||||
nextElement = javaClass; | |||||
} | |||||
} finally { | } finally { | ||||
inFileStream.close(); | inFileStream.close(); | ||||
} | } | ||||
@@ -224,52 +224,52 @@ public class jlink { | |||||
} | } | ||||
ZipFile zipf = new ZipFile(f); | ZipFile zipf = new ZipFile(f); | ||||
try { | try { | ||||
Enumeration entries = zipf.entries(); | |||||
while (entries.hasMoreElements()) { | |||||
ZipEntry inputEntry = (ZipEntry) entries.nextElement(); | |||||
//Ignore manifest entries. They're bound to cause conflicts between | |||||
//files that are being merged. User should supply their own | |||||
//manifest file when doing the merge. | |||||
String inputEntryName = inputEntry.getName(); | |||||
int index = inputEntryName.indexOf("META-INF"); | |||||
if (index < 0) { | |||||
//META-INF not found in the name of the entry. Go ahead and process it. | |||||
try { | |||||
output.putNextEntry(processEntry(zipf, inputEntry)); | |||||
} catch (ZipException ex) { | |||||
//If we get here, it could be because we are trying to put a | |||||
//directory entry that already exists. | |||||
//For example, we're trying to write "com", but a previous | |||||
//entry from another mergefile was called "com". | |||||
//In that case, just ignore the error and go on to the | |||||
//next entry. | |||||
String mess = ex.getMessage(); | |||||
if (mess.indexOf("duplicate") >= 0) { | |||||
//It was the duplicate entry. | |||||
continue; | |||||
} else { | |||||
// I hate to admit it, but we don't know what happened | |||||
// here. Throw the Exception. | |||||
throw ex; | |||||
Enumeration entries = zipf.entries(); | |||||
while (entries.hasMoreElements()) { | |||||
ZipEntry inputEntry = (ZipEntry) entries.nextElement(); | |||||
//Ignore manifest entries. They're bound to cause conflicts between | |||||
//files that are being merged. User should supply their own | |||||
//manifest file when doing the merge. | |||||
String inputEntryName = inputEntry.getName(); | |||||
int index = inputEntryName.indexOf("META-INF"); | |||||
if (index < 0) { | |||||
//META-INF not found in the name of the entry. Go ahead and process it. | |||||
try { | |||||
output.putNextEntry(processEntry(zipf, inputEntry)); | |||||
} catch (ZipException ex) { | |||||
//If we get here, it could be because we are trying to put a | |||||
//directory entry that already exists. | |||||
//For example, we're trying to write "com", but a previous | |||||
//entry from another mergefile was called "com". | |||||
//In that case, just ignore the error and go on to the | |||||
//next entry. | |||||
String mess = ex.getMessage(); | |||||
if (mess.indexOf("duplicate") >= 0) { | |||||
//It was the duplicate entry. | |||||
continue; | |||||
} else { | |||||
// I hate to admit it, but we don't know what happened | |||||
// here. Throw the Exception. | |||||
throw ex; | |||||
} | |||||
} | } | ||||
} | |||||
InputStream in = zipf.getInputStream(inputEntry); | |||||
int len = buffer.length; | |||||
int count = -1; | |||||
InputStream in = zipf.getInputStream(inputEntry); | |||||
int len = buffer.length; | |||||
int count = -1; | |||||
while ((count = in.read(buffer, 0, len)) > 0) { | |||||
output.write(buffer, 0, count); | |||||
while ((count = in.read(buffer, 0, len)) > 0) { | |||||
output.write(buffer, 0, count); | |||||
} | |||||
in.close(); | |||||
output.closeEntry(); | |||||
} | } | ||||
in.close(); | |||||
output.closeEntry(); | |||||
} | } | ||||
} | |||||
} finally { | } finally { | ||||
zipf.close(); | |||||
zipf.close(); | |||||
} | } | ||||
} | } | ||||
@@ -117,25 +117,25 @@ public class AntSoundPlayer implements LineListener, BuildListener { | |||||
DataLine.Info info = new DataLine.Info(Clip.class, format, | DataLine.Info info = new DataLine.Info(Clip.class, format, | ||||
AudioSystem.NOT_SPECIFIED); | AudioSystem.NOT_SPECIFIED); | ||||
try { | try { | ||||
try { | |||||
audioClip = (Clip) AudioSystem.getLine(info); | |||||
audioClip.addLineListener(this); | |||||
audioClip.open(audioInputStream); | |||||
} catch (LineUnavailableException e) { | |||||
project.log("The sound device is currently unavailable"); | |||||
return; | |||||
} catch (IOException e) { | |||||
e.printStackTrace(); | |||||
} | |||||
try { | |||||
audioClip = (Clip) AudioSystem.getLine(info); | |||||
audioClip.addLineListener(this); | |||||
audioClip.open(audioInputStream); | |||||
} catch (LineUnavailableException e) { | |||||
project.log("The sound device is currently unavailable"); | |||||
return; | |||||
} catch (IOException e) { | |||||
e.printStackTrace(); | |||||
} | |||||
if (duration != null) { | |||||
playClip(audioClip, duration.longValue()); | |||||
} else { | |||||
playClip(audioClip, loops); | |||||
} | |||||
audioClip.drain(); | |||||
if (duration != null) { | |||||
playClip(audioClip, duration.longValue()); | |||||
} else { | |||||
playClip(audioClip, loops); | |||||
} | |||||
audioClip.drain(); | |||||
} finally { | } finally { | ||||
audioClip.close(); | |||||
audioClip.close(); | |||||
} | } | ||||
} else { | } else { | ||||
project.log("Can't get data from file " + file.getName()); | project.log("Can't get data from file " + file.getName()); | ||||
@@ -198,12 +198,12 @@ public class ResourceList extends DataType implements ResourceCollection { | |||||
Union streamResources = new Union(); | Union streamResources = new Union(); | ||||
BufferedReader reader = new BufferedReader(crh.getAssembledReader()); | BufferedReader reader = new BufferedReader(crh.getAssembledReader()); | ||||
try { | try { | ||||
streamResources.setCache(true); | |||||
streamResources.setCache(true); | |||||
String line = null; | |||||
while ((line = reader.readLine()) != null) { | |||||
streamResources.add(parse(line)); | |||||
} | |||||
String line = null; | |||||
while ((line = reader.readLine()) != null) { | |||||
streamResources.add(parse(line)); | |||||
} | |||||
} finally { | } finally { | ||||
reader.close(); | reader.close(); | ||||
} | } | ||||