Java OutputStream Write Int writeInt(OutputStream out, int x)

Here you can find the source of writeInt(OutputStream out, int x)

Description

Writes an integer to the output stream.

License

MIT License

Parameter

Parameter Description
out The output stream
x The integer

Exception

Parameter Description
IOException if an I/O error occurs.

Declaration

public static void writeInt(OutputStream out, int x) throws IOException 

Method Source Code

//package com.java2s;
/*/*from   w  w  w  .  ja v  a  2s.co  m*/
 * This file is part of ReplayStudio, licensed under the MIT License (MIT).
 *
 * Copyright (c) 2016 johni0702 <https://github.com/johni0702>
 * Copyright (c) contributors
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

import java.io.IOException;

import java.io.OutputStream;

public class Main {
    /**
     * Writes an integer to the output stream.
     * @param out The output stream
     * @param x The integer
     * @throws IOException if an I/O error occurs.
     */
    public static void writeInt(OutputStream out, int x) throws IOException {
        out.write((x >>> 24) & 0xFF);
        out.write((x >>> 16) & 0xFF);
        out.write((x >>> 8) & 0xFF);
        out.write(x & 0xFF);
    }
}

Related

  1. writeInt(OutputStream out, int value)
  2. writeInt(OutputStream out, int value)
  3. writeInt(OutputStream out, int value)
  4. writeInt(OutputStream out, int value)
  5. writeInt(OutputStream out, int x)
  6. writeInt(OutputStream output, int value)
  7. writeInt(OutputStream outputStream, int integerToWrite)
  8. writeInt(OutputStream stream, int value)