public static void copyResource(Project theProject,
String theResourceName,
File theDestFile) throws IOException {
InputStream in =
ResourceUtils.class.getResourceAsStream(theResourceName);
if (in == null)
{
throw new IOException("Resource '" + theResourceName
+ "' not found");
}
OutputStream out = null;
try
{
out = new FileOutputStream(theDestFile);
byte buf[] = new byte[4096];
int numBytes = 0;
while ((numBytes = in.read(buf)) > 0)
{
out.write(buf, 0, numBytes);
}
}
finally
{
if (in != null)
{
in.close();
}
if (out != null)
{
out.close();
}
}
}
Copies a container resource from the JAR into the specified file. |