This is a utility method that can be used to dump the contents of the idToIidDB to a txt file.

@param dumpFilename
Full path to the file where the dump will be written.
@throws Exception
480986
public void dumpidToIidDB(String dumpFilename) throws Exception {
		DatabaseEntry foundKey = new DatabaseEntry();
		DatabaseEntry foundData = new DatabaseEntry();

		ForwardCursor cursor = idToIidDB.openCursor(null, null);
		BufferedWriter out = new BufferedWriter(new FileWriter(new File(dumpFilename)));
		while (cursor.getNext(foundKey, foundData, LockMode.DEFAULT) == OperationStatus.SUCCESS) {
			int iid = IntegerBinding.entryToInt(foundData);
			String id = StringBinding.entryToString(foundKey);
			out.write(id + " " + iid + "\n");
		}
		cursor.close();
		out.close();
	}
149375
@Override
    public void writeXML(String fileName) throws IOException {
        OutputStream out = new FileOutputStream(fileName);
        if (fileName.endsWith(".gz")) {
            out = new GZIPOutputStream(out);
        }
        writeXML(out);
    }
9780
private void writeID(String contents, String currentID) throws IOException{

		String localName = getLocalFileName(currentID);

		try ( PrintWriter pw = new PrintWriter(new GZIPOutputStream(new FileOutputStream(localName))) ) {

			pw.print(contents);
			pw.flush();
		}
	}
656451
public OvhDump serviceName_dump_dumpId_GET(String serviceName, Long dumpId) throws IOException {
		String qPath = "/hosting/privateDatabase/{serviceName}/dump/{dumpId}";
		StringBuilder sb = path(qPath, serviceName, dumpId);
		String resp = exec(qPath, "GET", sb.toString(), null);
		return convertTo(resp, OvhDump.class);
	}
1191908
private void openInputFile(final String inputFileName) throws IOException
	{
		myInputFile = new File(inputFileName);
		myInputStream = new FileInputStream(myInputFile);
		myStreamReader = new InputStreamReader(myInputStream, getInputEncodingCode());
		myBufferedReader = new BufferedReader(myStreamReader);
		myLineReader = new LineNumberReader(myBufferedReader);
	}
680578
public void encode(DerOutputStream out) throws IOException {
        DerOutputStream tmp = new DerOutputStream();
        name.encode(tmp);
        int nameType = name.getType();
        if (nameType == GeneralNameInterface.NAME_ANY ||
            nameType == GeneralNameInterface.NAME_X400 ||
            nameType == GeneralNameInterface.NAME_EDI) {

            // implicit, constructed form
            out.writeImplicit(DerValue.createTag(DerValue.TAG_CONTEXT,
                              true, (byte)nameType), tmp);
        } else if (nameType == GeneralNameInterface.NAME_DIRECTORY) {
            // explicit, constructed form since underlying tag is CHOICE
            // (see X.680 section 30.6, part c)
            out.write(DerValue.createTag(DerValue.TAG_CONTEXT,
                                         true, (byte)nameType), tmp);
        } else {
            // implicit, primitive form
            out.writeImplicit(DerValue.createTag(DerValue.TAG_CONTEXT,
                              false, (byte)nameType), tmp);
        }
    }
1353611
public void save(String fileName)
      throws FileNotFoundException, UnsupportedEncodingException {
    try (PrintWriter writer = new PrintWriter(fileName, "UTF-8")) {
      for (Map.Entry<String, Integer> entry : data.entrySet()) {
        writer.println(String.format("%d;%s", entry.getValue(), entry.getKey()));
      }
    }
  }
1071281
@Reqiured
    public void setDumpDirectory(String dumpDirectory) {
        if (dumpDirectory != null && dumpDirectory.trim().length() > 0) {
            File file = new File(dumpDirectory);
            if (file.exists() || file.mkdirs()) {
                this.dumpDirectory = file;
            }
        }
    }
1086822
public static String getFileContents(String pFileName) throws IOException{
         String fileContents = null;
         InputStream is = new FileInputStream(pFileName);
         BufferedReader reader = new BufferedReader(new InputStreamReader(is));
         StringBuffer xml = new StringBuffer();
         String aLine = null;
         while((aLine = reader.readLine()) != null){
           xml.append(aLine);
           xml.append("\n");

         }
        reader.close();
        fileContents = xml.toString();
        return fileContents;
    }
791425
public static void dump(DataSource dataSource, File outputFile) {
    try (Log log = Log.create(outputFile)) {
      log.write(CallInfo.create(), executeQuery(dataSource));
    } 
  }
988465
private void writeDocument(String fullDocument, String filename) {
		// create output file handle
		File outFile = new File(mOutputDir, filename+".xml"); 
		
		BufferedWriter bw = null;
		try {
			// create a buffered writer for the output file
			bw = new BufferedWriter(new FileWriter(outFile));
			bw.append(fullDocument);
			
		} catch (IOException e) { // something went wrong with the bufferedwriter
			e.printStackTrace();
			Logger.printError(component, "File "+outFile.getAbsolutePath()+" could not be written.");
		} finally { // clean up for the bufferedwriter
			try {
				bw.close();
			} catch(IOException e) {
				e.printStackTrace();
				Logger.printError(component, "File "+outFile.getAbsolutePath()+" could not be closed.");
			}
		}
	}
722438
public static void main(final String[] args) throws Exception
    {
        if (args.length == 0)
        {
            System.err.format("Usage: %s <filenames>...%n", SbeTool.class.getName());
            System.exit(-1);
        }

        for (final String fileName : args)
        {
            final Ir ir;
            if (fileName.endsWith(".xml"))
            {
                final String xsdFilename = System.getProperty(SbeTool.VALIDATION_XSD);
                if (xsdFilename != null)
                {
                    validateAgainstSchema(fileName, xsdFilename);
                }

                ir = new IrGenerator().generate(parseSchema(fileName), System.getProperty(TARGET_NAMESPACE));
            }
            else if (fileName.endsWith(".sbeir"))
            {
                ir = new IrDecoder(fileName).decode();
            }
            else
            {
                System.err.println("Input file format not supported: " + fileName);
                System.exit(-1);
                return;
            }

            final String outputDirName = System.getProperty(OUTPUT_DIR, ".");
            if (Boolean.parseBoolean(System.getProperty(GENERATE_STUBS, "true")))
            {
                final String targetLanguage = System.getProperty(TARGET_LANGUAGE, "Java");

                generate(ir, outputDirName, targetLanguage);
            }

            if (Boolean.parseBoolean(System.getProperty(GENERATE_IR, "false")))
            {
                final File inputFile = new File(fileName);
                final String inputFilename = inputFile.getName();
                final int nameEnd = inputFilename.lastIndexOf('.');
                final String namePart = inputFilename.substring(0, nameEnd);
                final File fullPath = new File(outputDirName, namePart + ".sbeir");

                try (IrEncoder irEncoder = new IrEncoder(fullPath.getAbsolutePath(), ir))
                {
                    irEncoder.encode();
                }
            }
        }
    }
448488
public void write(String filename)
	{
		try
		{
			write(new FileOutputStream(filename));
		}
		catch (FileNotFoundException e)
		{
			e.printStackTrace();
		}
	}
245675
public static final void fileDump(String fileName, byte[] data)
   {
      try
      {
         FileOutputStream os = new FileOutputStream(fileName);
         os.write(data);
         os.close();
      }

      catch (IOException ex)
      {
         ex.printStackTrace();
      }
   }
205249
public void write() throws IOException {
        OutputStream outStream = null;
        XMLStreamWriter out = null;
        try {
            outStream = new FileOutputStream(jobFile);
            out = XMLOutputFactory.newInstance().createXMLStreamWriter(outStream, "UTF-8");
            out.writeStartDocument();
            out.writeStartElement(ELEMENT_JOB);
            for (final Map.Entry<String, Object> e: prop.entrySet()) {
                out.writeStartElement(ELEMENT_PROPERTY);
                out.writeAttribute(ATTRIBUTE_NAME, e.getKey());
                if (e.getValue() instanceof String) {
                    out.writeStartElement(ELEMENT_STRING);
                    out.writeCharacters(e.getValue().toString());
                    out.writeEndElement(); //string
                } else if (e.getValue() instanceof Set) {
                    out.writeStartElement(ELEMENT_SET);
                    final Set<?> s = (Set<?>) e.getValue();
                    for (final Object o: s) {
                        out.writeStartElement(ELEMENT_STRING);
                        out.writeCharacters(o.toString());
                        out.writeEndElement(); //string
                    }
                    out.writeEndElement(); //set
                } else if (e.getValue() instanceof Map) {
                    out.writeStartElement(ELEMENT_MAP);
                    final Map<?, ?> s = (Map<?, ?>) e.getValue();
                    for (final Map.Entry<?, ?> o: s.entrySet()) {
                        out.writeStartElement(ELEMENT_ENTRY);
                        out.writeAttribute(ATTRIBUTE_KEY, o.getKey().toString());
                        out.writeStartElement(ELEMENT_STRING);
                        out.writeCharacters(o.getValue().toString());
                        out.writeEndElement(); //string
                        out.writeEndElement(); //entry
                    }
                    out.writeEndElement(); //string
                } else {
                    out.writeStartElement(e.getValue().getClass().getName());
                    out.writeCharacters(e.getValue().toString());
                    out.writeEndElement(); //string
                }
                out.writeEndElement(); //property
            }
            out.writeStartElement(ELEMENT_FILES);
            for (final FileInfo i: files.values()) {
                out.writeStartElement(ELEMENT_FILE);
                if (i.src != null) {
                    out.writeAttribute(ATTRIBUTE_SRC, i.src.toString());
                }
                out.writeAttribute(ATTRIBUTE_URI, i.uri.toString());
                out.writeAttribute(ATTRIBUTE_PATH, i.file.getPath());
                if (i.result != null) {
                    out.writeAttribute(ATTRIBUTE_RESULT, i.result.toString());
                }
                if (i.format != null) {
                    out.writeAttribute(ATTRIBUTE_FORMAT, i.format);
                }
                try {
                    for (Map.Entry<String, Field> e: attrToFieldMap.entrySet()) {
                        final boolean v = e.getValue().getBoolean(i);
                        if (v) {
                            out.writeAttribute(e.getKey(), Boolean.TRUE.toString());
                        }
                    }
                } catch (final IllegalAccessException ex) {
                    throw new RuntimeException(ex);
                }
                out.writeEndElement(); //file
            }
            out.writeEndElement(); //files
            out.writeEndElement(); //job
            out.writeEndDocument();
        } catch (final IOException e) {
            throw new IOException("Failed to write file: " + e.getMessage());
        } catch (final XMLStreamException e) {
            throw new IOException("Failed to serialize job file: " + e.getMessage());
        } finally {
            if (out != null) {
                try {
                    out.close();
                } catch (final XMLStreamException e) {
                    throw new IOException("Failed to close file: " + e.getMessage());
                }
            }
            if (outStream != null) {
                try {
                    outStream.close();
                } catch (final IOException e) {
                    throw new IOException("Failed to close file: " + e.getMessage());
                }
            }
        }
        lastModified = jobFile.lastModified();
    }
1027548
public void writeNameValuePair(String name, double value) throws IOException
   {
      internalWriteNameValuePair(name, Double.toString(value));
   }
1034870
public static void dumpAnalysisToFile(String outputDirName,
                                          String baseFileName,
                                          PartitionBalance partitionBalance) {
        if(outputDirName != null) {
            File outputDir = new File(outputDirName);
            if(!outputDir.exists()) {
                Utils.mkdirs(outputDir);
            }

            try {
                FileUtils.writeStringToFile(new File(outputDirName, baseFileName + ".analysis"),
                                            partitionBalance.toString());
            } catch(IOException e) {
                logger.error("IOException during dumpAnalysisToFile: " + e);
            }
        }
    }