- import
java.io.File; - import
java.io.FileInputStream; - import
java.io.FileNotFoundException; - import
java.io.FileOutputStream; - import
java.io.IOException; - import
java.io.InputStream; - import
java.io.OutputStream; -
-
- public
class Test { -
public static void main(String[] args) { -
} -
-
-
public void copy(File source, File target) { -
File tarpath = new File(target, source.getName()); -
if (source.isDirectory()) { -
tarpath.mkdir(); -
File[] dir = source.listFiles(); -
for (int i = 0; i < dir.length; i++) { -
copy(dir[i], tarpath); -
} -
} else { -
try { -
InputStream is = new FileInputStream(source); -
OutputStream os = new FileOutputStream(tarpath); -
byte[] buf = new byte[1024]; -
int len = 0; -
while ((len = is.read(buf)) != -1) { -
os.write(buf, 0, len); -
} -
is.close(); -
os.close(); -
} catch (FileNotFoundException e) { -
e.printStackTrace(); -
} catch (IOException e) { -
e.printStackTrace(); -
} -
} -
} - }
- import
java.text.SimpleDateFormat; - import
java.util.Calendar; -
-
- public
class Test { -
public static void main(String[] args) { -
Calendar cal = Calendar.getInstance(); -
cal.add(Calendar.DAY_OF_MONTH, 1000); -
System.out.println(new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime())); -
} - }