src/main/java/org/jfree/graphics2d/svg/SVGUtils.java
public static void writeToSVG(File file, String svgElement, boolean zip) 
            throws IOException {    
        BufferedWriter writer = null;
        try {
            OutputStream os = new FileOutputStream(file);
            if (zip) {
                os = new GZIPOutputStream(os);
            }
            OutputStreamWriter osw = new OutputStreamWriter(os, "UTF-8");
            writer = new BufferedWriter(osw);
            writer.write("<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n");
            writer.write(svgElement + "\n");
            writer.flush();
        } finally {
            try {
                if (writer != null) {
                    writer.close();
                }
            } catch (IOException ex) {
                throw new RuntimeException(ex);
            }
        } 
    }
public static void writeToSVG(File file, String svgElement, boolean zip) 
            throws IOException {    
        BufferedWriter writer = null;
        try {
            OutputStream os = new FileOutputStream(file);
            if (zip) {
                os = new GZIPOutputStream(os);
            }
            OutputStreamWriter osw = new OutputStreamWriter(os, "UTF-8");
            writer = new BufferedWriter(osw);
            writer.write("<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n");
            writer.write(svgElement + "\n");
            writer.flush();
        } finally {
            try {
                if (writer != null) {
                    writer.close();
                }
            } catch (IOException ex) {
                throw new RuntimeException(ex);
            }
        } 
    }
public static void writeToSVG ( File file , String svgElement , boolean zip ) throws IOException { BufferedWriter writer = null ; try { OutputStream os = new FileOutputStream ( file ) ; if ( zip ) { os = new GZIPOutputStream ( os ) ; } OutputStreamWriter osw = new OutputStreamWriter ( os , "UTF-8" ) ; writer = new BufferedWriter ( osw ) ; writer . write ( "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n" ) ; writer . write ( svgElement + "\n" ) ; writer . flush ( ) ; } finally { try { if ( writer != null ) { writer . close ( ) ; } } catch ( IOException ex ) { throw new RuntimeException ( ex ) ; } } }
Writes a file containing the SVG element.

@param file  the file ({@code null} not permitted).
@param svgElement  the SVG element ({@code null} not permitted).
@param zip  compress the output.

@throws IOException if there is an I/O problem.

@since 3.0
Writes a file containing the SVG element .