MCPcopy Create free account
hub / github.com/demoth/jake2 / CopyFile

Method CopyFile

server/src/main/java/jake2/server/SV_CCMDS.java:93–152  ·  view source on GitHub ↗
(String src, String dst)

Source from the content-addressed store, hash-verified

91 ================
92 */
93 private static void CopyFile(String src, String dst) {
94 RandomAccessFile f1, f2;
95 int l = -1;
96 byte buffer[] = new byte[65536];
97
98 //Com.DPrintf("CopyFile (" + src + ", " + dst + ")\n");
99 try {
100 f1 = new RandomAccessFile(src, "r");
101 }
102 catch (Exception e) {
103 return;
104 }
105 try {
106 f2 = new RandomAccessFile(dst, "rw");
107 }
108 catch (Exception e) {
109 try {
110 f1.close();
111 }
112 catch (IOException e1) {
113 e1.printStackTrace();
114 }
115 return;
116 }
117
118 while (true) {
119
120 try {
121 l = f1.read(buffer, 0, 65536);
122 }
123 catch (IOException e1) {
124
125 e1.printStackTrace();
126 }
127 if (l == -1)
128 break;
129 try {
130 f2.write(buffer, 0, l);
131 }
132 catch (IOException e2) {
133
134 e2.printStackTrace();
135 }
136 }
137
138 try {
139 f1.close();
140 }
141 catch (IOException e1) {
142
143 e1.printStackTrace();
144 }
145 try {
146 f2.close();
147 }
148 catch (IOException e2) {
149
150 e2.printStackTrace();

Callers 1

SV_CopySaveGameMethod · 0.95

Calls 2

readMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected