java複製檔案工具類

2021-06-09 14:19:16 字數 638 閱讀 1347

public int copy(string source_name,string dest_name,int type) throws ioexception 

if (!source_filefile.canread())

if (dest_filefile.exists())

else

}else

}else

if (!parentdir.canwrite())

//複製檔案

sourcefileinputstream=new fileinputstream(source_filefile);

destination=new fileoutputstream(dest_filefile);

buffer=new byte[1024];

while(true)

destination.write(buffer, 0, bytes_read);}}

} finally

catch (ioexception e)

}if (destination!=null) catch (ioexception e)

}return result;

} }

Java工具類 Java檔案工具類

public class fileutils 讀取檔案並作為byte返回 param file 目標檔案 return throws ioexception public static byte readfileasbytes file file throws ioexception 讀取檔案並作為...

物件屬性複製工具類

具有相同屬性名稱的物件之間的屬性值複製,具體 如下 public class beanutil 複製物件屬性 param from param to param excludsarray 排除屬性列表 throws exception public static void copypropertie...

Java反射工具類

反射工具類 public class reflectionutil return field.get object catch exception e return null 通過反射獲取靜態成員的值 param classvar param fieldname return 靜態成員的值 supp...