+ /**
+ * Write a mapping done in a file.
+ * @param _mp The mapping done to be write
+ * @param _path File's path
+ * @param _file File's name
+ */
+ public static void writeMapping( Mapping _mp, String _path, String _file )
+ {
+ if( _file.equals( "" ) )
+ {
+ System.err.println( "No file's name !\n" ) ;
+ return ;
+ }
+
+ if ( ! _file.endsWith( ".xml" ) )
+ {
+ _file = _file + ".xml"; // On ajoute l'extension xml au nom du fichier
+ }
+
+ if( ! _file.equals( "" ) )
+ {
+ String path = "" ;
+
+ if( _path.length() != 0 )
+ {
+ path = _path+"/"+_file ;
+ } else {
+ path = new String( "./" + _file ) ;
+ }
+
+ XStream xstream = new XStream( new DomDriver() ) ;
+
+ String xml = xstream.toXML( _mp ) ;
+
+ PrintWriter ecrivain = null ;
+
+ try {
+ ecrivain = new PrintWriter( new OutputStreamWriter( new FileOutputStream( path ), "UTF8" ) ) ;
+
+ ecrivain.println( "<?xml version=\"1.0\" encoding=\"UTF8\"?>" ) ;
+ ecrivain.println( xml ) ;
+
+ ecrivain.close() ;
+ } catch( Exception e ) {
+ System.err.println( "\nError during the write opération !\n" ) ;
+ e.printStackTrace() ;
+ }
+ }
+ }
+
+