private void rename ( String from , String to ) throws IOException { IndexOutputStream out = null ; IndexInputStream in = null ; try { out = new IndexOutputStream ( dir . createOutput ( to ) ) ; in = new IndexInputStream ( dir . openInput ( from ) ) ; DirectoryHelper . transfer ( in , out ) ; } finally { if ( in != null ) { in . close ( ) ; } if ( out != null ) { out . flush ( ) ; out . close ( ) ; } } try { // delete old one if ( dir . fileExists ( from ) ) { dir . deleteFile ( from ) ; } } catch ( IOException e ) { // do noting. Will be removed later if ( LOG . isTraceEnabled ( ) ) { LOG . trace ( "Can't deleted file: " + e . getMessage ( ) ) ; } } }
Renames file by copying .