Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
org.bukkit.util.FileUtil Class Reference

Static Public Member Functions

static boolean copy (File inFile, File outFile)
 

Detailed Description

Class containing file utilities

Definition at line 12 of file FileUtil.java.

Member Function Documentation

static boolean org.bukkit.util.FileUtil.copy ( File  inFile,
File  outFile 
)
static

This method copies one file to another location

Parameters
inFilethe source filename
outFilethe target filename
Returns
true on success

Definition at line 21 of file FileUtil.java.

21  {
22  if (!inFile.exists()) {
23  return false;
24  }
25 
26  FileChannel in = null;
27  FileChannel out = null;
28 
29  try {
30  in = new FileInputStream(inFile).getChannel();
31  out = new FileOutputStream(outFile).getChannel();
32 
33  long pos = 0;
34  long size = in.size();
35 
36  while (pos < size) {
37  pos += in.transferTo(pos, 10 * 1024 * 1024, out);
38  }
39  } catch (IOException ioe) {
40  return false;
41  } finally {
42  try {
43  if (in != null) {
44  in.close();
45  }
46  if (out != null) {
47  out.close();
48  }
49  } catch (IOException ioe) {
50  return false;
51  }
52  }
53 
54  return true;
55 
56  }

The documentation for this class was generated from the following file: