Description
Make a PrintWriter to send outgoing data.
License
Open Source License
Parameter
Parameter | Description |
---|
socket | a parameter |
Exception
Parameter | Description |
---|
IOException | an exception |
Declaration
public static PrintWriter getWriter(Socket socket) throws IOException
Method Source Code
//package com.java2s;
/******************************************************************************
* Copyright (C) Devamatre Inc. 2009 - 2018. All rights reserved.
* // w w w . j a v a2 s .c o m
* This code is licensed to Devamatre under one or more contributor license
* agreements. The reproduction, transmission or use of this code, in source
* and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* Devamatre reserves the right to modify the technical specifications and or
* features without any prior notice.
*****************************************************************************/
import java.io.IOException;
import java.io.PrintWriter;
import java.net.Socket;
public class Main {
/**
* Make a PrintWriter to send outgoing data. This PrintWriter will
* automatically flush stream when <code>println(...)</code> is called.
*
*
* @param socket
* @return
* @throws IOException
*/
public static PrintWriter getWriter(Socket socket) throws IOException {
/* autoFlush set to be true */
return (new PrintWriter(socket.getOutputStream(), true));
}
}
Related
- copy(final Socket inputSocket, final Socket outputSocket)
- createObjectOutputStream(Socket socket)
- createWriter(Socket socket)
- getOutputStream(Socket socket)
- getOutputStreamFromSocket(final Socket socket)
- openWriter(Socket socket)
- writeData(Socket id, byte[] data, int len)
- writeDatasIntoSocket(Socket socket, String datas)
- writeFromServer(Socket sck, String row)