|
34 | 34 | import java.io.InputStreamReader;
|
35 | 35 | import java.io.OutputStream;
|
36 | 36 | import java.io.Reader;
|
| 37 | +import java.nio.file.Files; |
| 38 | +import java.nio.file.LinkOption; |
37 | 39 | import java.util.HashMap;
|
38 | 40 | import java.util.HashSet;
|
39 | 41 | import java.util.Map.Entry;
|
|
47 | 49 | import org.openide.util.EditableProperties;
|
48 | 50 |
|
49 | 51 | // Copied from org.netbeans.upgrade.CopyFiles
|
| 52 | +// Modified to not display UI and use java.nio.file.Files.copy() |
50 | 53 | /** Does copy of files according to include/exclude patterns.
|
51 | 54 | *
|
52 | 55 | * @author Jiri Skrivanek
|
| 56 | + * @author Jiri Sedlacek |
53 | 57 | */
|
54 | 58 | final class CopyFiles extends Object {
|
55 | 59 |
|
@@ -123,39 +127,9 @@ private static String getRelativePath(File root, File file) {
|
123 | 127 | */
|
124 | 128 | private static void copyFile(File sourceFile, File targetFile) throws IOException {
|
125 | 129 | ensureParent(targetFile);
|
126 |
| - InputStream ins = null; |
127 |
| - OutputStream out = null; |
128 |
| - try { |
129 |
| - ins = new FileInputStream(sourceFile); |
130 |
| - out = new FileOutputStream(targetFile); |
131 |
| - copy(ins, out); |
132 |
| - } finally { |
133 |
| - if (ins != null) { |
134 |
| - ins.close(); |
135 |
| - } |
136 |
| - if (out != null) { |
137 |
| - out.close(); |
138 |
| - } |
139 |
| - } |
| 130 | + Files.copy(sourceFile.toPath(), targetFile.toPath(), LinkOption.NOFOLLOW_LINKS); |
140 | 131 | }
|
141 | 132 |
|
142 |
| - |
143 |
| - // --- Copied from org.openide.filesystems.FileUtil ------------------------ |
144 |
| - private static void copy(InputStream is, OutputStream os) throws IOException { |
145 |
| - final byte[] BUFFER = new byte[65536]; |
146 |
| - int len; |
147 |
| - |
148 |
| - for (;;) { |
149 |
| - len = is.read(BUFFER); |
150 |
| - |
151 |
| - if (len == -1) { |
152 |
| - return; |
153 |
| - } |
154 |
| - |
155 |
| - os.write(BUFFER, 0, len); |
156 |
| - } |
157 |
| - } |
158 |
| - // ------------------------------------------------------------------------- |
159 | 133 |
|
160 | 134 | /** Copy given file to target root dir if matches include/exclude patterns.
|
161 | 135 | * If properties pattern is applicable, it copies only matching keys.
|
|
0 commit comments