Write this BugCollection to a file as XML.

@param file
the file to write to
541812
public void writeXML(File file) throws IOException {
        OutputStream out = new FileOutputStream(file);
        if (file.getName().endsWith(".gz")) {
            out = new GZIPOutputStream(out);
        }
        writeXML(out);
    }
228047
@Override
    public void writeXML(@WillClose Writer out) throws IOException {
        assert project != null;
        bugsPopulated();
        XMLOutput xmlOutput;
        // if (project == null) throw new NullPointerException("No project");


        xmlOutput = new OutputStreamXMLOutput(out);

        writeXML(xmlOutput);
    }
1276320
public static void writeTextFile(String text,File file) throws IOException
    {
        Writer writer=null;
        try
        {
            //create writer to file (with default encoding)
            OutputStream outputStream=new FileOutputStream(file);
            writer=IOHelper.createWriter(outputStream,null);
            
            //write to file
            writer.write(text);
        }
        finally
        {
            //close writer
            IOHelper.closeResource(writer);
        }
    }
142485
public void loadXml(String fileName) throws CoreException {
        if (fileName == null) {
            return;
        }
        st = new StopTimer();

        // clear markers
        clearMarkers(null);

        final Project findBugsProject = new Project();
        final Reporter bugReporter = new Reporter(javaProject, findBugsProject, monitor);
        bugReporter.setPriorityThreshold(userPrefs.getUserDetectorThreshold());

        reportFromXml(fileName, findBugsProject, bugReporter);
        // Merge new results into existing results.
        updateBugCollection(findBugsProject, bugReporter, false);
        monitor.done();
    }
953937
public void write(File file) throws Exception {
        try {
            FileOutputStream fos = new FileOutputStream(file);
            write(fos);
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        }
    }
963820
public static void writeToFile(byte[] catalogBytes, File file) throws IOException {
        JarOutputStream jarOut = new JarOutputStream(new FileOutputStream(file));

        JarInputStream jarIn = new JarInputStream(new ByteArrayInputStream(catalogBytes));
        JarEntry catEntry = null;
        JarInputStreamReader reader = new JarInputStreamReader();
        while ((catEntry = jarIn.getNextJarEntry()) != null) {
            byte[] value = reader.readEntryFromStream(jarIn);
            String key = catEntry.getName();

            assert (value != null);
            JarEntry entry = new JarEntry(key);
            entry.setSize(value.length);
            entry.setTime(System.currentTimeMillis());
            jarOut.putNextEntry(entry);
            jarOut.write(value);
            jarOut.flush();
            jarOut.closeEntry();
        }

        jarOut.finish();
        jarIn.close();
    }
826524
public static void serialize(final File file, final ClassHierarchy classHierarchy) throws IOException {
    final ClassHierarchyProto.Node node = serializeNode(classHierarchy.getNamespace());
    try (final FileOutputStream output = new FileOutputStream(file)) {
      try (final DataOutputStream dos = new DataOutputStream(output)) {
        node.writeTo(dos);
      }
    }
  }
77709
public <TYPE> void write(@NotNull final TYPE obj, @NotNull final File file, @NotNull final JAXBContext jaxbContext)
            throws MarshalObjectException {

        Contract.requireArgNotNull("obj", obj);
        Contract.requireArgNotNull("file", file);
        Contract.requireArgNotNull("jaxbContext", jaxbContext);

        try {
            final FileWriter fw = new FileWriter(file);
            try {
                write(obj, fw, jaxbContext);
            } finally {
                fw.close();
            }
        } catch (final IOException ex) {
            throw new MarshalObjectException("Unable to write XML to file: " + file, ex);
        }
    }
1311381
public static void parse(DocListener document, String file) {
        XmlParser p = new XmlParser();
        p.go(document, file);
    }
789756
public void toFile(File file) throws IOException {
		String[] sitemap = toStringArray();
		try(BufferedWriter writer = new BufferedWriter(new FileWriter(file))) {
			for (String string : sitemap) {
				writer.write(string);
			}
		}
	}
863657
public static void save(final File file, final Dependencies dependencies) {
        Utils4J.checkNotNull("file", file);
        Utils4J.checkValidFile(file);
        final XStream xstream = createXStream();
        try {
            final Writer writer = new FileWriter(file);
            try {
                xstream.toXML(dependencies, writer);
            } finally {
                writer.close();
            }
        } catch (final IOException ex) {
            throw new RuntimeException(ex);
        }
    }
867825
public static void toPemFile(final @NonNull PublicKey publicKey, final @NonNull File file)
			throws IOException {
		PublicKeyWriter.writeInPemFormat(publicKey, file);
	}
102488
public static Document readXML(File file) {
		Assert.notNull(file, "Xml file is null !");
		if (false == file.exists()) {
			throw new UtilException("File [{}] not a exist!", file.getAbsolutePath());
		}
		if (false == file.isFile()) {
			throw new UtilException("[{}] not a file!", file.getAbsolutePath());
		}

		try {
			file = file.getCanonicalFile();
		} catch (IOException e) {
			// ignore
		}

		BufferedInputStream in = null;
		try {
			in = FileUtil.getInputStream(file);
			return readXML(in);
		} finally {
			IoUtil.close(in);
		}
	}
1013881
public static void writeXML(Document xmldocument, Writer writer) throws IOException {
		assert xmldocument != null : AssertMessages.notNullParameter(0);
		assert writer != null : AssertMessages.notNullParameter(1);
		writeNode(xmldocument, writer);
	}
560753
public void addOutputFile(String file) {
        if (file != null) {
            File f = new File(file);
            if (f.isDirectory()) {
                throw new IllegalArgumentException("output file parameter points to a directory, must be a file");
            } else if (f.exists() && !f.canWrite()) {
                throw new IllegalArgumentException(
                        "output file parameter points to a file we have no write permissions");
            }

            setOutputFile(f);
        }
    }
304457
public static XNElement parseXML(File file) throws IOException, XMLStreamException {
        try (InputStream in = new FileInputStream(file)) {
            return parseXML(in);
        }
    }
1207423
public void writePom(File file) throws ProjectException {
        log.debug("Writing pom: {}", file.getPath());

        Project copy = this;
        copy.removeProperty( "project.basedir" );

        Writer writer;
        try {
            writer = new BufferedWriter(new FileWriter(file));
        } catch (IOException e) {
            throw new ProjectException(e);
        }

        MavenXpp3Writer pomWriter = new MavenXpp3Writer();
        try {
            pomWriter.write(writer, copy.mavenModel);
        } catch (IOException e) {
            throw new ProjectException("Failed to write pom", e);
        }
    }