Java Socket Write getOutputStreamFromSocket(final Socket socket)

Here you can find the source of getOutputStreamFromSocket(final Socket socket)

Description

Returns a OutputStream from the specified socket

License

Open Source License

Parameter

Parameter Description
socket the socket the OutputStream is connected to.

Exception

Parameter Description
IOException if a error occurs while connecting to the server.

Return

the OutputStream connected to the specified socket.

Declaration

public static OutputStream getOutputStreamFromSocket(final Socket socket)
        throws IOException 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2013 Joe Beeton./*from  ww w  .  j ava 2  s. c o  m*/
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser Public License v2.1
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * 
 * Contributors:
 *     Joe Beeton - initial API and implementation
 ******************************************************************************/

import java.io.IOException;

import java.io.OutputStream;
import java.net.Socket;

public class Main {
    /**
     * Returns a OutputStream from the specified socket
     * @param socket the socket the OutputStream is connected to.
     * @return the OutputStream connected to the specified socket.
     * @throws IOException if a error occurs while connecting to the server.
     */
    public static OutputStream getOutputStreamFromSocket(final Socket socket)
            throws IOException {
        return socket.getOutputStream();
    }
}

Related

  1. copy(final Socket inputSocket, final Socket outputSocket)
  2. createObjectOutputStream(Socket socket)
  3. createWriter(Socket socket)
  4. getOutputStream(Socket socket)
  5. getWriter(Socket socket)
  6. openWriter(Socket socket)
  7. writeData(Socket id, byte[] data, int len)
  8. writeDatasIntoSocket(Socket socket, String datas)