String uuidDoc = UUID.randomUUID().toString();
Calendar date = Calendar.getInstance();
int year = date.get(Calendar.YEAR);
int month = date.get(Calendar.MONTH) + 1;
int day = date.get(Calendar.DAY_OF_MONTH);
String afterPath = year + "\\" + month + "\\" + day + "\\" + uuidDoc + ".doc";
String newPath = impl.getDirPaths() + afterPath; //新文件
//拷贝文件 int length=2097152; File f1 = new File(oldPath); File f2 = new File(newPath); int bytesum = 0; int byteread = 0; if(f2.createNewFile()){ FileInputStream inStream = new FileInputStream(f1); FileOutputStream outStream = new FileOutputStream(f2); byte[] buffer=new byte[length]; while((byteread = inStream.read(buffer)) != -1){ bytesum += byteread; //字节数 文件大小 outStream.write(buffer, 0, byteread); } inStream.close(); }