Writes this {@link WeightedDirectedMultigraph} instance to the specified
file.  Note that because the Pajek format does not support parallel
edges, all parallel edges in one direction are flatted into a single
directed edge.
549837
public <T> void write(WeightedDirectedMultigraph<T> g, File f) 
            throws IOException {
        write(g, f, null);
    }
1149311
public void write(Tree<?, ?> tree) throws IOException {
        this.writer.append("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n"); //$NON-NLS-1$
        this.writer.append("<gxl>\n"); //$NON-NLS-1$

        if (tree != null) {
            this.writer.append("\t<graph id=\""); //$NON-NLS-1$
            this.writer.append(Integer.toHexString(System.identityHashCode(new Integer(tree.hashCode()))));
            this.writer.append("-"); //$NON-NLS-1$
            this.writer.append(Integer.toString(this.graphIndex++));
            this.writer.append("\" edgeids=\"true\" edgemode=\"directed\">\n"); //$NON-NLS-1$

            // Write the node attributes
            Iterator<? extends TreeNode<?, ?>> iterator = tree.broadFirstIterator();
            TreeNode<?, ?> node;
            int dataCount;
            while (iterator.hasNext()) {
                node = iterator.next();
                dataCount = node.getUserDataCount();
                final String name = "NODE" + Integer.toHexString(node.hashCode()); //$NON-NLS-1$
                final String label = Integer.toString(dataCount);

                this.writer.append("\t\t<node id=\""); //$NON-NLS-1$
                this.writer.append(name);
                this.writer.append("\">\n"); //$NON-NLS-1$

                this.writer.append("\t\t\t<attr name=\"label\">\n"); //$NON-NLS-1$
                this.writer.append("\t\t\t\t<string>"); //$NON-NLS-1$
                this.writer.append(label);
                this.writer.append("</string>\n"); //$NON-NLS-1$
                this.writer.append("\t\t\t</attr>\n"); //$NON-NLS-1$

                this.writer.append("\t\t</node>\n"); //$NON-NLS-1$
            }

            // Write the node attributes
            iterator = tree.broadFirstIterator();
            TreeNode<?, ?> child;
            String childName;
            while (iterator.hasNext()) {
                node = iterator.next();
                final String name = "NODE" + Integer.toHexString(node.hashCode()); //$NON-NLS-1$
                if (!node.isLeaf()) {
                    final int childCount = node.getChildCount();
                    for (int i = 0; i < childCount; ++i) {
                        child = node.getChildAt(i);
                        if (child != null) {
                            childName = "NODE" + Integer.toHexString(child.hashCode()); //$NON-NLS-1$

                            this.writer.append("\t\t<edge id=\""); //$NON-NLS-1$
                            this.writer.append(name);
                            this.writer.append("--"); //$NON-NLS-1$
                            this.writer.append(childName);
                            this.writer.append("\" isdirected=\"true\" from=\""); //$NON-NLS-1$
                            this.writer.append(name);
                            this.writer.append("\" to=\""); //$NON-NLS-1$
                            this.writer.append(childName);
                            this.writer.append("\">\n"); //$NON-NLS-1$

                            this.writer.append("\t\t\t<attr name=\"label\">\n"); //$NON-NLS-1$
                            this.writer.append("\t\t\t\t<string>"); //$NON-NLS-1$
                            this.writer.append(Integer.toString(i));
                            this.writer.append("</string>\n"); //$NON-NLS-1$
                            this.writer.append("\t\t\t</attr>\n"); //$NON-NLS-1$

                            this.writer.append("\t\t</edge>\n"); //$NON-NLS-1$
                        }
                    }
                }
            }

            this.writer.append("\t</graph>\n"); //$NON-NLS-1$
        }

        this.writer.append("</gxl>\n"); //$NON-NLS-1$
    }
415954
public static void saveGraph(DirectedGraph<Integer, DefaultEdge> graph, String location) throws IOException {
		File file = new File(location);
		file.createNewFile();
		if (!file.canWrite()) {
			throw new IOException("Cannot write to file " + location);
		}
		GraphSerialization.saveGraph(graph, file);
	}
385237
public static void writeEdge(Node src, Node tgt, Edge edge,
            PrintWriter writer) {
        StringBuilder sb = new StringBuilder();
        RelationshipType rel = edge.rel;
        String reldispval = rel.getDisplayValue();
        sb.append("  <edge label='");
        String dispval = format(EDGE_LABEL, src.label, rel, tgt.label);
        sb.append(dispval);
        sb.append("' source='");
        sb.append(edge.source.toString());
        sb.append("' target='");
        sb.append(edge.target.toString());
        sb.append("'>\n");
        sb.append("    <att name='relationship type'");
        sb.append(" value='");
        sb.append(reldispval);
        sb.append("' />\n");

        // Edge graphics
        String color = color(rel);
        String graphics = format(EDGE_GRAPHICS, 1, color, 1, reldispval);
        sb.append(graphics);

        sb.append("  </edge>\n");
        writer.write(sb.toString());
    }
809023
public void write( byte[] b, int off, int len ) throws IOException {
        if( file.isOpen() == false && file instanceof SmbNamedPipe ) {
            file.send( new TransWaitNamedPipe( "\\pipe" + file.unc ),
                                    new TransWaitNamedPipeResponse() );
        }
        writeDirect( b, off, len, 0 );
    }
1163284
def write(self, mfile="multiplicons.txt", sfile="segments.txt",
              clobber=False):
        
        if not clobber:
            if os.path.isfile(mfile):
                raise IOError("Multiplicon file %s already exists." % mfile)
            if os.path.isfile(sfile):
                raise IOError("Segments file %s already exists." % sfile)
        self._write_multiplicons(mfile)
        self._write_segments(sfile)
1355630
public void write(@NonNull MultiNormalizerStandardize normalizer, @NonNull OutputStream stream) throws IOException {
        try (DataOutputStream dos = new DataOutputStream(stream)) {
            dos.writeBoolean(normalizer.isFitLabel());
            dos.writeInt(normalizer.numInputs());
            dos.writeInt(normalizer.isFitLabel() ? normalizer.numOutputs() : -1);

            for (int i = 0; i < normalizer.numInputs(); i++) {
                Nd4j.write(normalizer.getFeatureMean(i), dos);
                Nd4j.write(normalizer.getFeatureStd(i), dos);
            }
            if (normalizer.isFitLabel()) {
                for (int i = 0; i < normalizer.numOutputs(); i++) {
                    Nd4j.write(normalizer.getLabelMean(i), dos);
                    Nd4j.write(normalizer.getLabelStd(i), dos);
                }
            }
            dos.flush();
        }
    }
1303262
public void writeGridInPmeshFormat(String outPutFileName, double cutOff) throws IOException {
        BufferedWriter writer = new BufferedWriter(new FileWriter(outPutFileName + ".pmesh"));
        boolean negative = false;
        if (cutOff < 0) {
            negative = true;
        } else {
            negative = false;
        }
        int numberOfGridPoints = 0;
        for (int z = 0; z < grid[0][0].length; z++) {
            for (int y = 0; y < grid[0].length; y++) {
                for (int x = 0; x < grid.length; x++) {
                    if (negative) {
                        if (grid[x][y][z] <= cutOff) {
                            numberOfGridPoints++;
                        }
                    } else {
                        if (grid[x][y][z] >= cutOff) {
                            numberOfGridPoints++;
                        }
                    }
                }
            }
        }
        writer.write(numberOfGridPoints + "\n");
        for (int z = 0; z < grid[0][0].length; z++) {
            for (int y = 0; y < grid[0].length; y++) {
                for (int x = 0; x < grid.length; x++) {
                    Point3d coords = getCoordinatesFromGridPoint(new Point3d(x, y, z));
                    if (negative) {
                        if (grid[x][y][z] <= cutOff) {
                            writer.write(coords.x + "\t" + coords.y + "\t" + coords.z + "\n");
                        }
                    } else {
                        if (grid[x][y][z] >= cutOff) {
                            writer.write(coords.x + "\t" + coords.y + "\t" + coords.z + "\n");
                        }
                    }
                }
            }
        }
        writer.close();
    }
385097
public int writeGraphToFile(byte[] img, File to)
	{
		try
		{
			FileOutputStream fos = new FileOutputStream(to);
			fos.write(img);
			fos.close();
		} catch (IOException ioe)
		{
			return -1;
		}

		return 1;

	}
997293
private void writeMultipleExp(String arg0, Map result) throws FileNotFoundException, IOException {

        arg0 = revisePath(arg0);
        ArrayList<HashMap> expArr = getObjectOr(result, "experiments", new ArrayList());
        ArrayList<HashMap> soilArr = getObjectOr(result, "soils", new ArrayList());
        ArrayList<HashMap> wthArr = getObjectOr(result, "weathers", new ArrayList());

        // Setup output file
        Calendar cal = Calendar.getInstance();
        if (!expArr.isEmpty() && soilArr.isEmpty() && wthArr.isEmpty()) {
            outputFile = new File(arg0 + "AGMIP_DSSAT_EXPERIMENTS_" + cal.getTimeInMillis() + ".zip");
        } else if (expArr.isEmpty() && !soilArr.isEmpty() && wthArr.isEmpty()) {
            outputFile = new File(arg0 + "AGMIP_DSSAT_SOILS_" + cal.getTimeInMillis() + ".zip");
        } else if (expArr.isEmpty() && soilArr.isEmpty() && !wthArr.isEmpty()) {
            outputFile = new File(arg0 + "AGMIP_DSSAT_WEATHERS_" + cal.getTimeInMillis() + ".zip");
        } else {
            outputFile = new File(arg0 + "AGMIP_DSSAT_" + cal.getTimeInMillis() + ".zip");
        }

        // Write files
        String soil_id;
        String wth_id;
        expArr = combineExps(expArr);
        for (HashMap expData : expArr) {
            ArrayList<HashMap> rootArr = getObjectOr(expData, "dssat_root", new ArrayList());
            if (rootArr.isEmpty()) {
                soil_id = getObjectOr(expData, "soil_id", "");
                wth_id = getObjectOr(expData, "wst_id", "");
                expData.put("soil", getSectionDataWithNocopy(soilArr, "soil_id", soil_id));
                expData.put("weather", getSectionDataWithNocopy(wthArr, "wst_id", wth_id));
                recordSWData(expData, new DssatSoilOutput());
                recordSWData(expData, new DssatWeatherOutput());
            } else {
                ArrayList<HashMap> soilArrTmp = new ArrayList();
                ArrayList<HashMap> wthArrTmp = new ArrayList();
                for (HashMap rootData : rootArr) {
                    soil_id = getObjectOr(rootData, "soil_id", "");
                    wth_id = getObjectOr(rootData, "wst_id", "");
                    HashMap soilTmp = new HashMap();
                    HashMap wthTmp = new HashMap();
                    soilTmp.put("soil", getSectionDataWithNocopy(soilArr, "soil_id", soil_id));
                    soilTmp.put("soil_id", soil_id);
                    soilTmp.put("exname", rootData.get("exname"));
                    soilTmp.put("id", rootData.get("id"));
                    wthTmp.put("weather", getSectionDataWithNocopy(wthArr, "wst_id", wth_id));
                    wthTmp.put("wst_id", wth_id);
                    recordSWData(soilTmp, new DssatSoilOutput());
                    recordSWData(wthTmp, new DssatWeatherOutput());
                    soilArrTmp.add((HashMap) soilTmp.get("soil"));
                    wthArrTmp.add(wthTmp);
                    rootData.put("wst_id", getObjectOr(wthTmp, "wst_id", wth_id));
                    rootData.put("soil_id", getObjectOr(soilTmp, "soil_id", wth_id));
                }
                expData.put("soil", soilArrTmp);
                expData.put("weather", wthArrTmp);
            }
            String exname = getValueOr(expData, "exname", "N/A");
            //            DssatCommonOutput[] outputs = {
//                new DssatXFileOutput(),
//                new DssatAFileOutput(),
//                new DssatTFileOutput(),
//                new DssatCulFileOutput(),};
            writeSingleExp(arg0, expData, new DssatXFileOutput(), exname + "_X");
            writeSingleExp(arg0, expData, new DssatAFileOutput(), exname + "_A");
            writeSingleExp(arg0, expData, new DssatTFileOutput(), exname + "_T");
            writeSingleExp(arg0, expData, new DssatCulFileOutput(), exname + "_Cul");
        }

        // If experiment data is included
        if (!expArr.isEmpty()) {
            // Write all batch files
            futFiles.put("DSSBatch.v45", executor.submit(new DssatTranslateRunner(new DssatBatchFileOutput(DssatVersion.DSSAT45), expArr, arg0)));
            futFiles.put("DSSBatch.v46", executor.submit(new DssatTranslateRunner(new DssatBatchFileOutput(DssatVersion.DSSAT46), expArr, arg0)));
            futFiles.put("Run45.bat", executor.submit(new DssatTranslateRunner(new DssatRunFileOutput(DssatVersion.DSSAT45), expArr, arg0)));
            futFiles.put("Run46.bat", executor.submit(new DssatTranslateRunner(new DssatRunFileOutput(DssatVersion.DSSAT46), expArr, arg0)));
        } // If only weather or soil data is included
        else {
            for (HashMap sData : soilArr) {
                HashMap tmp = new HashMap();
                tmp.put("soil", sData);
                tmp.put("soil_id", getObjectOr(sData, "soil_id", ""));
                recordSWData(tmp, new DssatSoilOutput());
            }
            for (HashMap wData : wthArr) {
                HashMap tmp = new HashMap();
                tmp.put("weather", wData);
                tmp.put("wst_id", getObjectOr(wData, "wst_id", ""));
                recordSWData(tmp, new DssatWeatherOutput());
            }
        }

        // Write soil and weather files
        writeWthFiles(arg0);
        writeSoilFiles(arg0);

        // compress all output files into one zip file
        //createZip();
    }
446293
public void write(DataOutput out) throws IOException {
        if (array == null) {
            out.write(NDARRAY_SER_VERSION_HEADER_NULL);
            return;
        }

        INDArray toWrite;
        if (array.isView()) {
            toWrite = array.dup();
        } else {
            toWrite = array;
        }

        //Write version header: this allows us to maintain backward compatibility in the future,
        // with features such as compression, sparse arrays or changes on the DataVec side
        out.write(NDARRAY_SER_VERSION_HEADER);
        Nd4j.write(toWrite, new DataOutputStream(new DataOutputWrapperStream(out)));
    }
22840
def write(filename, mesh):
    
    if mesh.points.shape[1] == 2:
        logging.warning(
            "PERMAS requires 3D points, but 2D points given. "
            "Appending 0 third component."
        )
        mesh.points = numpy.column_stack(
            [mesh.points[:, 0], mesh.points[:, 1], numpy.zeros(mesh.points.shape[0])]
        )

    opener = gzip.open if filename.endswith(".gz") else open

    with opener(filename, "wb") as fh:
        fh.write(
            "\n".join(
                [
                    "!",
                    "! File written by meshio version {}".format(__version__),
                    "! Further information available at {}".format(__website__),
                    "!",
                    "$ENTER COMPONENT NAME = DFLT_COMP DOFTYPE = DISP MATH",
                    "    $SITUATION NAME = REAL_MODES",
                    "        DFLT_COMP SYSTEM = NSV CONSTRAINTS = SPCVAR_1 ! LOADING = LOADVAR_1",
                    "    $END SITUATION" "!",
                    "!",
                    "    $STRUCTURE",
                    "!" "\n",
                ]
            ).encode("utf-8")
        )

        # Write nodes
        fh.write("        $COOR NSET = ALL_NODES\n".encode("utf-8"))
        for k, x in enumerate(mesh.points):
            fh.write(
                "        {:8d} {:+.15f} {:+.15f} {:+.15f}\n".format(
                    k + 1, x[0], x[1], x[2]
                ).encode("utf-8")
            )

        meshio_to_permas_type = {
            "vertex": (1, "PLOT1"),
            "line": (2, "PLOTL2"),
            "triangle": (3, "TRIA3"),
            "quad": (4, "QUAD4"),
            "tetra": (4, "TET4"),
            "hexahedron": (8, "HEXE8"),
            "wedge": (6, "PENTA6"),
            "pyramid": (5, "PYRA5"),
        }
        #
        # Avoid non-unique element numbers in case of multiple element types by
        # num_ele !!!
        #
        num_ele = 0

        for meshio_type, cell in mesh.cells.items():
            numcells, num_local_nodes = cell.shape
            permas_type = meshio_to_permas_type[meshio_type]
            fh.write("!\n".encode("utf-8"))
            fh.write(
                "        $ELEMENT TYPE = {} ESET = {}\n".format(
                    permas_type[1], permas_type[1]
                ).encode("utf-8")
            )
            for k, c in enumerate(cell):
                form = "        {:8d} " + " ".join(num_local_nodes * ["{:8d}"]) + "\n"
                fh.write(form.format(k + num_ele + 1, *(c + 1)).encode("utf-8"))
            num_ele += numcells

        fh.write("!\n".encode("utf-8"))
        fh.write("    $END STRUCTURE\n".encode("utf-8"))
        fh.write("!\n".encode("utf-8"))
        elem_3D = ["HEXE8", "TET4", "PENTA6", "PYRA5"]
        elem_2D = ["TRIA3", "QUAD4"]
        elem_1D = ["PLOT1", "PLOTL2"]
        fh.write("    $SYSTEM NAME = NSV\n".encode("utf-8"))
        fh.write("!\n".encode("utf-8"))
        fh.write("        $ELPROP\n".encode("utf-8"))
        for meshio_type, cell in mesh.cells.items():
            permas_type = meshio_to_permas_type[meshio_type]
            if permas_type[1] in elem_3D:
                fh.write(
                    "            {} MATERIAL = DUMMY_MATERIAL\n".format(
                        permas_type[1]
                    ).encode("utf-8")
                )
            elif permas_type[1] in elem_2D:
                fh.write(
                    (
                        12 * " "
                        + "{} GEODAT = GD_{} MATERIAL = DUMMY_MATERIAL\n".format(
                            permas_type[1], permas_type[1]
                        )
                    ).encode("utf-8")
                )
            else:
                assert permas_type[1] in elem_1D
        fh.write("!\n".encode("utf-8"))
        fh.write("        $GEODAT SHELL  CONT = THICK  NODES = ALL\n".encode("utf-8"))
        for meshio_type, cell in mesh.cells.items():
            permas_type = meshio_to_permas_type[meshio_type]
            if permas_type[1] in elem_2D:
                fh.write(
                    (12 * " " + "GD_{} 1.0\n".format(permas_type[1])).encode("utf-8")
                )
        fh.write(
            """!
!
    $END SYSTEM
!
    $CONSTRAINTS NAME = SPCVAR_1
    $END CONSTRAINTS
!
    $LOADING NAME = LOADVAR_1
    $END LOADING
!
$EXIT COMPONENT
!
$ENTER MATERIAL
!
    $MATERIAL NAME = DUMMY_MATERIAL TYPE = ISO
!
        $ELASTIC  GENERAL  INPUT = DATA
            2.0E+05 0.3
!
        $DENSITY  GENERAL  INPUT = DATA
            7.8E-09
!
        $THERMEXP  GENERAL  INPUT = DATA
            1.2E-05
!
    $END MATERIAL
!
$EXIT MATERIAL
!
$FIN
""".encode(
                "utf-8"
            )
        )
    return
264221
private void write() throws IOException
   {
      m_projectFile.validateUniqueIDsForMicrosoftProject();

      writeFileCreationRecord();
      writeProjectHeader(m_projectFile.getProjectProperties());

      if (m_projectFile.getResources().isEmpty() == false)
      {
         m_resourceModel = new ResourceModel(m_projectFile, m_locale);
         m_writer.write(m_resourceModel.toString());
         for (Resource resource : m_projectFile.getResources())
         {
            writeResource(resource);
         }
      }

      if (m_projectFile.getTasks().isEmpty() == false)
      {
         m_taskModel = new TaskModel(m_projectFile, m_locale);
         m_writer.write(m_taskModel.toString());
         writeTasks(m_projectFile.getChildTasks());
      }

      m_writer.flush();
   }
401617
final long writeEdge(int edgeId, int nodeA, int nodeB, int nextEdgeA, int nextEdgeB) {
        if (edgeId < 0 || edgeId == EdgeIterator.NO_EDGE)
            throw new IllegalStateException("Cannot write edge with illegal ID:" + edgeId + "; nodeA:" + nodeA + ", nodeB:" + nodeB);

        long edgePointer = toPointer(edgeId);
        edges.setInt(edgePointer + E_NODEA, nodeA);
        edges.setInt(edgePointer + E_NODEB, nodeB);
        edges.setInt(edgePointer + E_LINKA, nextEdgeA);
        edges.setInt(edgePointer + E_LINKB, nextEdgeB);
        return edgePointer;
    }
1232254
@Override
    protected void write(List<Message> msgList) throws IOException {
        for (Message msg : msgList) {
            writer.writeTo(msg);

            String routingKey = normalizeRoutingKey(msg);

            DynamicCounter.increment(
                    MonitorConfig.builder("writtenMessages")
                            .withTag(TagKey.DATA_SOURCE, routingKey)
                            .build());
            ++writtenMessages;
            DynamicCounter.increment(
                    MonitorConfig.builder("writtenBytes")
                            .withTag(TagKey.DATA_SOURCE, routingKey)
                            .build(), msg.getPayload().length);
            writtenBytes += msg.getPayload().length;

            messageWrittenInRotation = true;
        }

        writer.sync();

        throughput.increment(msgList.size());
    }
774470
@Override
    public void writeFile(String arg0, ArrayList<HashMap> results) {
        writeFile(arg0, new HashMap());
    }
461899
public static void saveGraph(DirectedGraph<Integer, DefaultEdge> graph, File file) throws IOException {
		SerializableDirectedGraph serialGraph = new SerializableDirectedGraph(graph);
		BufferedOutputStream fos;
		ObjectOutputStream out;
		fos = new BufferedOutputStream(new FileOutputStream(file));
		out = new ObjectOutputStream(fos);
		out.writeObject(serialGraph);
		out.close();

	}