There are some files inside the folder
folder kept in the
jar file, which I am copying one by one to
temp directory as shown in my below code. Could someone please tell me how do I use a loop to copy all the files from the folder
folder to
temp directory
String path = System.getProperty("java.io.tmpdir");
File dir = new File(path+"\\folder");
dir.mkdirs();
InputStream is1=Main.class.getClass().getResourceAsStream("/input/folder/file1.txt");
try
{
File.createTempFile("file1", ".txt",dir.getCanonicalFile());
}
catch (IOException e)
{
e.printStackTrace();
}
File dstfile1=new File(dir,"\\file1.txt");
dstfile1.deleteOnExit();
FileOutputStream fos1 = new FileOutputStream(dstfile1);
int b1;
while((b1 = is1.read()) != -1)
{
fos1.write(b1);
}
fos1.close();
.
.
.
InputStream is2=Main.class.getClass().getResourceAsStream("/input/folder/file2.txt");
try
{
File.createTempFile("file2", ".txt",dir.getCanonicalFile());
}
catch (IOException e)
{
e.printStackTrace();
}
File dstfile2=new File(dir,"\\file2.txt");
dstfile1.deleteOnExit();
FileOutputStream fos2 = new FileOutputStream(dstfile2);
int b2;
while((b2 = is2.read()) != -1)
{
fos2.write(b2);
}
fos2.close();