question: public static void changeUID ( long oldUID , long newUID , String fromFile , String toFile ) throws Exception { String inputFile ; String tempFile ; File file ; String content ; String line ; BufferedReader reader ; BufferedWriter writer ; if ( ! isKOML ( fromFile ) ) { inputFile = fromFile + ".koml" ; binaryToKOML ( fromFile , inputFile ) ; } else { inputFile = fromFile ; } reader = new BufferedReader ( new FileReader ( inputFile ) ) ; content = "" ; while ( ( line = reader . readLine ( ) ) != null ) { if ( ! content . equals ( "" ) ) content += "\n" ; content += line ; } reader . close ( ) ; content = content . replaceAll ( " uid='" + Long . toString ( oldUID ) + "'" , " uid='" + Long . toString ( newUID ) + "'" ) ; tempFile = inputFile + ".temp" ; writer = new BufferedWriter ( new FileWriter ( tempFile ) ) ; writer . write ( content ) ; writer . flush ( ) ; writer . close ( ) ; if ( ! isKOML ( toFile ) ) { komlToBinary ( tempFile , toFile ) ; } else { writer = new BufferedWriter ( new FileWriter ( toFile ) ) ; writer . write ( content ) ; writer . flush ( ) ; writer . close ( ) ; } file = new File ( tempFile ) ; file . delete ( ) ; }
target:  changes the oldUID into newUID from the given file (binary/KOML) into the other one (binary/KOML). it basically does a replace in the XML, i.e. it looks for " uid='oldUID'" and replaces it with " uid='newUID'".