List of utility methods to do Socket Write
void | copy(final Socket inputSocket, final Socket outputSocket) Copy data from input socket to output socket InputStream inputStream = null; OutputStream outputStream = null; try { inputStream = inputSocket.getInputStream(); outputStream = outputSocket.getOutputStream(); final byte buf[] = new byte[3000]; int length; while (true) { ... |
ObjectOutputStream | createObjectOutputStream(Socket socket) create Object Output Stream return new ObjectOutputStream(socket.getOutputStream()); |
PrintWriter | createWriter(Socket socket) create Writer return new PrintWriter(socket.getOutputStream()); |
OutputStream | getOutputStream(Socket socket) get Output Stream try { return socket.getOutputStream(); } catch (IOException e) { e.printStackTrace(); return null; |
OutputStream | getOutputStreamFromSocket(final Socket socket) Returns a OutputStream from the specified socket return socket.getOutputStream();
|
PrintWriter | getWriter(Socket socket) Make a PrintWriter to send outgoing data. return (new PrintWriter(socket.getOutputStream(), true)); |
PrintWriter | openWriter(Socket socket) open Writer PrintWriter writer = new PrintWriter(socket.getOutputStream(), true); return writer; |
void | writeData(Socket id, byte[] data, int len) Method writeData OutputStream output; output = id.getOutputStream(); output.write(data, 0, len); |
void | writeDatasIntoSocket(Socket socket, String datas) write Datas Into Socket DataOutputStream dos = new DataOutputStream(socket.getOutputStream());
dos.writeBytes(datas);
dos.flush();
|
void | writeFromServer(Socket sck, String row) write From Server PrintStream out = new PrintStream(new BufferedOutputStream(sck.getOutputStream())); for (int i = 0; i < 100; i++) { out.print(row); out.print("\r\n"); out.flush(); |