Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class PrvKolokvium_Grupa2 {
- public void copyLargeTxtFiles(String from, String to, long size) throws IOException{
- File f = new File(from);
- File t = new File(to);
- if(!f.exists()){
- System.out.println("Ne postoi");
- return;
- }
- if(!t.exists()){
- t.mkdirs();
- }
- File[] files = f.listFiles();
- for (File file : files) {
- if(file.getName().endsWith(".txt") && file.length() > size){
- FileInputStream fis = null;
- FileOutputStream fos = null;
- try {
- fis = new FileInputStream(file);
- File newFile = new File(to, file.getName());
- fos = new FileOutputStream(newFile);
- int b;
- while((b = fis.read()) == -1){
- fos.write(b);
- }
- } catch (Exception e) {
- // TODO: handle exception
- }finally{
- if(fis != null){
- fis.close();
- }
- if(fos != null){
- fos.flush();
- fos.close();
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement