EXTRACTION OF FILE FROM INSIDE A CURRENT RUNNING JAR
public static void Extarctdll(String filename) throws IOException
{
try
{
System.out.println("called..");
InputStream ddlStream = <currentClass>.class
.getClassLoader().getResourceAsStream(filename);
FileOutputStream fos = null;
try {
fos = new FileOutputStream("D:\\Data\\"+filename);
byte[] buf = new byte[2048];
int r = ddlStream.read(buf);
while(r != -1) {
fos.write(buf, 0, r);
r = ddlStream.read(buf);
}
System.out.println("File copied..");
} finally {
if(fos != null) {
fos.close();
}
}
}
catch(Exception ex)
{
System.out.println("ERROR.."+ex.getMessage());
}
}
No comments:
Post a Comment