//this is example of function that takes root to the folder where target file lies, and copy there file
//Contracts_Postpaid_80.xls to the file Contracts_For_VVL.xls which will be created
public void copyContractsForVVL(String folder) {
InputStream inStream = null;
OutputStream outStream = null;
try {
File fileToCopy = new File(folder + "//Contracts_Postpaid_80.xls");
File copiedFile = new File(folder + "//Contracts_For_VVL.xls");
inStream = new FileInputStream(fileToCopy);
outStream = new FileOutputStream(copiedFile);
byte[] buffer = new byte[1024];
int length;
//copy the file content in bytes
while ((length = inStream.read(buffer)) > 0) {
outStream.write(buffer, 0, length);
}
inStream.close();
outStream.close();
System.out.println("File is copied successful!");
} catch (IOException e) {
e.printStackTrace();
}
}
//Contracts_Postpaid_80.xls to the file Contracts_For_VVL.xls which will be created
public void copyContractsForVVL(String folder) {
InputStream inStream = null;
OutputStream outStream = null;
try {
File fileToCopy = new File(folder + "//Contracts_Postpaid_80.xls");
File copiedFile = new File(folder + "//Contracts_For_VVL.xls");
inStream = new FileInputStream(fileToCopy);
outStream = new FileOutputStream(copiedFile);
byte[] buffer = new byte[1024];
int length;
//copy the file content in bytes
while ((length = inStream.read(buffer)) > 0) {
outStream.write(buffer, 0, length);
}
inStream.close();
outStream.close();
System.out.println("File is copied successful!");
} catch (IOException e) {
e.printStackTrace();
}
}
No comments:
Post a Comment