Writes the class file to disk in the given directory.

@param targetDir   The target directory
@param classWriter The current class writer
@param className   The class name
@throws IOException if there is a problem writing the class to disk
423544
protected void writeClassToDisk(File targetDir, ClassWriter classWriter, String className) throws IOException {
        if (targetDir != null) {

            String fileName = className.replace('.', '/') + ".class";
            File targetFile = new File(targetDir, fileName);
            targetFile.getParentFile().mkdirs();

            try (OutputStream outputStream = Files.newOutputStream(targetFile.toPath())) {
                writeClassToDisk(outputStream, classWriter);
            }
        }
    }
912269
public void write() throws IOException {
		{
			Filer filer = processingEnv.getFiler();
			String generateClassName =
					jsonModel.getPackageName() + "." + jsonModel.getTarget() + postfix;
			JavaFileObject fileObject = filer.createSourceFile(generateClassName, classElement);
			Template.writeGen(fileObject, jsonModel);
		}
		if (jsonModel.isBuilder()) {
			Filer filer = processingEnv.getFiler();
			String generateClassName =
					jsonModel.getPackageName() + "." + jsonModel.getTarget() + "JsonMeta";
			JavaFileObject fileObject = filer.createSourceFile(generateClassName, classElement);
			Template.writeJsonMeta(fileObject, jsonModel);
		}
	}
1025629
public static void write(ObjectOutput out, java.lang.reflect.Constructor constr) throws IOException {
        Class cl;

        if (constr == null) {
            ClassRef.write(out, null);
        } else {
            cl = constr.getDeclaringClass();
            ClassRef.write(out, cl);
            ClassRef.writeClasses(out, constr.getParameterTypes());
        }
    }
1235446
public FileObject write(ClassSymbol c)
        throws IOException
    {
        String className = c.flatName().toString();
        FileObject outFile
            = fileManager.getFileForOutput(StandardLocation.NATIVE_HEADER_OUTPUT,
                "", className.replaceAll("[.$]", "_") + ".h", null);
        Writer out = outFile.openWriter();
        try {
            write(out, c);
            if (verbose)
                log.printVerbose("wrote.file", outFile);
            out.close();
            out = null;
        } finally {
            if (out != null) {
                // if we are propogating an exception, delete the file
                out.close();
                outFile.delete();
                outFile = null;
            }
        }
        return outFile; // may be null if write failed
    }
787661
public void write(Object from, File target) throws IOException {
    OutputStream outputStream = new FileOutputStream(target);
    try {
      write(from, outputStream);
    } finally {
      outputStream.close();
    }
  }
223281
@Override
   public void writeClassBody(Definition def, Writer out) throws IOException
   {

      out.write("public class " + getClassName(def) + " implements Connection");
      writeLeftCurlyBracket(out, 0);
      int indent = 1;

      writeDefaultConstructor(def, out, indent);

      //constructor
      writeWithIndent(out, indent, "/**\n");
      writeWithIndent(out, indent, " * Default constructor\n");
      writeWithIndent(out, indent, " * @param connSpec ConnectionSpec\n");
      writeWithIndent(out, indent, " */\n");

      writeWithIndent(out, indent, "public " + getClassName(def) + "(ConnectionSpec connSpec)");
      writeLeftCurlyBracket(out, indent);
      writeRightCurlyBracket(out, indent);
      writeEol(out);

      writeClose(def, out, indent);
      writeInteraction(def, out, indent);
      writeLocalTransaction(def, out, indent);
      writeMetaData(def, out, indent);
      writeResultSetInfo(def, out, indent);

      writeEol(out);
      writeWithIndent(out, indent, "/**\n");
      writeWithIndent(out, indent, " * Set ManagedConnection\n");
      writeWithIndent(out, indent, " */\n");
      writeWithIndent(out, indent,
            "void setManagedConnection(" + def.getMcfDefs().get(getNumOfMcf()).getMcClass() + " mc)");
      writeLeftCurlyBracket(out, indent);
      writeRightCurlyBracket(out, indent);

      writeRightCurlyBracket(out, 0);
   }
721600
protected void write(Writer writer, WritingVisitor visitor) throws IOException {
      if( isNullObject() ){
         writer.write(JSONNull.getInstance().toString());
      }

      boolean b = false;
      Iterator keys = visitor.keySet(this).iterator();
      writer.write('{');

      while( keys.hasNext() ){
         if( b ){
            writer.write(',');
         }
         Object k = keys.next();
         writer.write(JSONUtils.quote(k.toString()));
         writer.write(':');
         Object v = this.properties.get(k);
         if( v instanceof JSON ){
            visitor.on((JSON) v, writer);
         }else{
            visitor.on(v, writer);
         }
         b = true;
      }
      writer.write('}');
   }
629708
IWriter buildWriter(final IClassContainer classContainer) {
        try {
            return new BufferedFileWriter(classContainer.getExportClassName(), path, format.getExtension());
        } catch (IOException e) {
            logger.warning(e.getMessage());
            return null;
        }
    }
352438
protected function rewriteClassMapWithLowerCaseClassNames($targetDir)
    {
        $classMapContents = file_get_contents($targetDir . '/autoload_classmap.php');
        $classMapContents = preg_replace_callback('/    \'[^\']*\' => /', function ($match) {
            return strtolower($match[0]);
        }, $classMapContents);
        file_put_contents($targetDir . '/autoload_classmap.php', $classMapContents);
    }
307922
@Override
   public void writeClassBody(Definition def, Writer out) throws IOException
   {

      out.write("public interface " + getClassName(def) + " extends Serializable, Referenceable");
      writeLeftCurlyBracket(out, 0);
      int indent = 1;

      writeConnection(def, out, indent);
      writeRightCurlyBracket(out, 0);
   }
954307
public static void write(Image image, File targetFile) throws IORuntimeException {
		ImageOutputStream out = null;
		try {
			out = getImageOutputStream(targetFile);
			write(image, FileUtil.extName(targetFile), out);
		} finally {
			IoUtil.close(out);
		}
	}
445235
protected void writeObject(java.io.DataOutputStream dataOutputStream)
                    throws ObjectManagerException, java.io.IOException
    {
        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.entry(this
                        , cclass
                        , "writeObject"
                        , new Object[] { dataOutputStream }
                            );

        try {
            dataOutputStream.writeByte(simpleSerialVersion);

        } catch (java.io.IOException exception) {
            // No FFDC Code Needed.
            ObjectManager.ffdc.processException(this, cclass, "writeObject", exception, "1:2111:1.34");

            if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
                trace.exit(this
                           , cclass
                           , "writeObject"
                           , "via PermanentIOException"
                                );
            throw new PermanentIOException(this,
                                           exception);
        } // catch (java.io.IOException exception).

        // We cannot check size as we are subclassed.

        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.exit(this,
                       cclass,
                       "writeObject");
    }
736219
public static void copy(final File sourceFile, File targetFile, final boolean overwrite) throws IOException {
        if (sourceFile == null) {
            throw new IOException("Source must not be null");
        }

        if (targetFile == null) {
            throw new IOException("Target must not be null");
        }

        // checks
        if ((false == sourceFile.isFile()) || (false == sourceFile.exists())) {
            throw new IOException("Source file '" + sourceFile.getAbsolutePath() + "' not found!");
        }

        if (true == targetFile.exists()) {
            if (true == targetFile.isDirectory()) {

                // Directory? -> use source file name
                targetFile = new File(targetFile, sourceFile.getName());
            } else if (true == targetFile.isFile()) {
                if (false == overwrite) {
                    throw new IOException("Target file '" + targetFile.getAbsolutePath() + "' already exists!");
                }
            } else {
                throw new IOException("Invalid target object '" + targetFile.getAbsolutePath() + "'!");
            }
        } else {
            // create parent dir
            FileUtils.forceMkdir(targetFile.getParentFile());
        }

        FileInputStream input = null;
        FileOutputStream output = null;

        try {
            input = new FileInputStream(sourceFile);
            output = new FileOutputStream(targetFile);
            copy(input, output);
            output.flush();
        } finally {
            IOUtils.closeQuietly(input);
            IOUtils.closeQuietly(output);
        }
    }
379197
public void write(OutputStream os)
    throws IOException
  {
    ByteCodeWriter out = new ByteCodeWriter(os, this);

    out.writeInt(MAGIC);
    out.writeShort(_minor);
    out.writeShort(_major);

    _constantPool.write(out);

    out.writeShort(_accessFlags);
    out.writeClass(_thisClass);
    out.writeClass(_superClass);

    out.writeShort(_interfaces.size());
    for (int i = 0; i < _interfaces.size(); i++) {
      String className = _interfaces.get(i);

      out.writeClass(className);
    }

    out.writeShort(_fields.size());
    for (int i = 0; i < _fields.size(); i++) {
      JavaField field = _fields.get(i);

      field.write(out);
    }

    out.writeShort(_methods.size());
    for (int i = 0; i < _methods.size(); i++) {
      JavaMethod method = _methods.get(i);

      method.write(out);
    }

    out.writeShort(_attributes.size());
    for (int i = 0; i < _attributes.size(); i++) {
      Attribute attr = _attributes.get(i);

      attr.write(out);
    }
  }
1225996
public JavaFileObject writeClass(ClassSymbol c)
        throws IOException, PoolOverflow, StringOverflow
    {
        JavaFileObject outFile
            = fileManager.getJavaFileForOutput(CLASS_OUTPUT,
                                               c.flatname.toString(),
                                               JavaFileObject.Kind.CLASS,
                                               c.sourcefile);
        OutputStream out = outFile.openOutputStream();
        try {
            writeClassFile(out, c);
            if (verbose)
                log.printVerbose("wrote.file", outFile);
            out.close();
            out = null;
        } finally {
            if (out != null) {
                // if we are propagating an exception, delete the file
                out.close();
                outFile.delete();
                outFile = null;
            }
        }
        return outFile; // may be null if write failed
    }
1111417
@Override
	public void writeEntry(String entryName, InputStream inputStream) throws IOException {
		JarArchiveEntry entry = new JarArchiveEntry(entryName);
		writeEntry(entry, new InputStreamEntryWriter(inputStream, true));
	}
1124194
public void writeClass(String className)
    throws IOException
  {
    ConstantPool pool =  _javaClass.getConstantPool();
    ClassConstant classConst = pool.getClass(className);

    if (classConst != null)
      writeShort(classConst.getIndex());
    else
      writeShort(0);
  }