File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed
src/main/java/cz/mallat/uasparser Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -188,7 +188,27 @@ protected List<Section> loadDataFromInternet() throws IOException {
188
188
List <Section > sections = fp .getSections ();
189
189
190
190
// now that we've finished parsing, we can save the temp copy
191
- tmpFile .renameTo (cacheFile );
191
+ Boolean result =tmpFile .renameTo (cacheFile );
192
+
193
+ if ( !result ){
194
+ // was across filesystems or target exists, or something else. Try other another way
195
+ // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4017593
196
+ InputStream inStream = new FileInputStream (tmpFile );
197
+ OutputStream outStream = new FileOutputStream (cacheFile );
198
+
199
+ byte [] buffer = new byte [4096 ];
200
+
201
+ int length ;
202
+ while ((length = inStream .read (buffer )) > 0 ){
203
+ outStream .write (buffer , 0 , length );
204
+ }
205
+
206
+ inStream .close ();
207
+ outStream .close ();
208
+
209
+ //delete the original file
210
+ tmpFile .delete ();
211
+ }
192
212
193
213
return sections ;
194
214
You can’t perform that action at this time.
0 commit comments