Package java.io

Examples of java.io.DataOutputStream


     * @param os the OutputStream that's handling outputlogging.
     * @param alsoToOutStream true if the out stream should still
     *        provide output, in addition to logging the ouput.
     */
    public static void directOutput(OutputStream os, boolean alsoToOutStream) {
        outputLog = new DataOutputStream(os);
        notifyOut = alsoToOutStream;
    }
View Full Code Here


     * @param os the DataOutputStream handling error logging.
     * @param alsoToErrStream true if the err stream should still
     *        provide output, in addition to logging the errors.
     */
    public static void directErrors(OutputStream os, boolean alsoToErrStream) {
        errorLog = new DataOutputStream(os);
        notifyErr = alsoToErrStream;
    }
View Full Code Here

        try {
            if (errorLog == null) {
                // If no errors have happened yet, this will get run.
                if (errorFile != null) {
                    FileOutputStream log = new FileOutputStream(errorFile.getPath(), errorAppend);
                    errorLog = new DataOutputStream(log);

                    // Lets make introductions into the error file,
                    // shall we?
                    errorLog.writeBytes("\n");
                    errorLog.writeBytes(getMapBeanMessage());
View Full Code Here

     * @param logStream the output stream for output.
     * @param alsoToStreams true if the streams should still provide
     *        output, in addition to logging the output.
     */
    public static void setLog(OutputStream logStream, boolean alsoToStreams) {
        DataOutputStream dos = new DataOutputStream(logStream);
        outputLog = dos;
        errorLog = dos;
        // Wrap up loose ends - if something happens to the
        // logStream, we'll just shut down logging, and force
        // everything to the output streams.
View Full Code Here

  public void write(School school) throws IOException
  {
    OutputStream out = null;
    try {
      out = school.createClassRoom(_classname);
      write(new DataOutputStream(out));
    } finally {
      if (out != null) {
        try {
          out.close();
        } catch (Throwable t) {
View Full Code Here

    }

    createConstructor(clazz, constants);

    ByteArrayOutputStream bytestream = new ByteArrayOutputStream();
    clazz.write(new DataOutputStream(bytestream));
    bytestream.close();

    //FileOutputStream fout = new FileOutputStream("/data/projects/anvil/src/"+classname+".class");
    //bytestream.writeTo(fout);
    //fout.close();
View Full Code Here

      code.invokestatic(method_ref);
    }
    code.areturn();

    ByteArrayOutputStream bytestream = new ByteArrayOutputStream();
    clazz.write(new DataOutputStream(bytestream));
    bytestream.close();

    Class cls = loader.define(classname, bytestream.toByteArray());
    return (GeneratorDispatcher)cls.newInstance()
  }
View Full Code Here

  {
    super(pool);
    _method = method;
    _codeindex = pool.addUtf8(ATTR_Code);
    _bytes = new Bytes();
    _code = new DataOutputStream(_bytes);
    if ((_method.getFlags() & ACC_STATIC) == 0) {
      _maxlocals++;
    }
  }
View Full Code Here

            if(LOG.isTraceEnabled()) {
                LOG.trace((ph.getStatus() == LEAF ? "Leaf " : "Branch ") + "Node#"
                        + page.getPageNum() + " - " + Arrays.toString(keys));
            }
            final FastMultiByteArrayOutputStream bos = new FastMultiByteArrayOutputStream(_fileHeader.getWorkSize());
            final DataOutputStream os = new DataOutputStream(bos);

            // write out the prefix
            final short prefixlen = ph.getPrefixLength();
            if(prefixlen > 0) {
                prefix.writeTo(os);
            }
            // Write out the Values
            Value prevKey = null;
            for(int i = 0; i < keys.length; i++) {
                final Value v = keys[i];
                if(v == prevKey) {
                    os.writeInt(-1);
                } else {
                    final int len = v.getLength();
                    final int size = len - prefixlen;
                    os.writeInt(size);
                    if(size > 0) {
                        v.writeTo(os, prefixlen, size);
                    }
                }
                prevKey = v;
            }
            // Write out the pointers
            for(int i = 0; i < ptrs.length; i++) {
                VariableByteCodec.encodeLong(ptrs[i], os);
            }
            // Write out link if current node is a leaf
            if(ph.getStatus() == LEAF) {
                os.writeLong(_prev);
                os.writeLong(_next);
            }

            writeValue(page, new Value(bos.toByteArray()));
            this.parentCache = null;
            setDirty(false);
View Full Code Here

        int[] data = new int[width * height];
        bi.getRGB(0, 0, width, height, data, 0, width);

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        DataOutputStream dos = new DataOutputStream(baos);

        try {
            int pixel, count, i, lastCount;
            if (!rawbits) {
                dos.writeBytes(regularMagicNumber);
                dos.writeBytes(" " + width);
                dos.writeBytes(" " + height);
                dos.writeBytes(" " + MAX_COLOR_VALUE + "\n");
                count = 0; // Keep lines less that 70 characters long

                // Keep track of the number of characters added per
                // pass
                lastCount = 0;

                Debug.output("PPMFormatter: Header is " + dos.size() + " bytes");
                Debug.output("PPMFormatter: Height = " + height);
                Debug.output("PPMFormatter: Width = " + width);
                Debug.output("PPMFormatter: data length = " + data.length);

                for (i = 0; i < data.length; i++) {

                    pixel = data[i];
                    int r = (pixel >>> 16) & 0x000000FF;
                    int g = (pixel >>> 8) & 0x000000FF;
                    int b = (pixel) & 0x000000FF;

                    dos.writeBytes(" " + r);
                    dos.writeBytes(" " + g);
                    dos.writeBytes(" " + b);
                    if (count > 57) {
                        dos.writeBytes("\n");
                        count = 0;
                    } else {
                        count += dos.size() - lastCount;
                    }
                    lastCount = dos.size();
                }
                Debug.output("PPMFormatter: after data, size is " + dos.size());

            } else {
                dos.writeBytes(rawbitsMagicNumber);
                dos.writeBytes(" " + width);
                dos.writeBytes(" " + height);
                dos.writeBytes(" " + MAX_COLOR_VALUE + "\n");
                for (i = 0; i < data.length; i++) {
                    pixel = data[i];
                    dos.writeByte(pixel >>> 16);
                    dos.writeByte(pixel >>> 8);
                    dos.writeByte(pixel);
                }
            }

            return baos.toByteArray();

View Full Code Here

TOP

Related Classes of java.io.DataOutputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.