Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ass.ullriher.hw8.server.impl;
- import ass.ullriher.hw8.server.ByteBufferUtil;
- import ass.ullriher.hw8.server.IResponse;
- import ass.ullriher.hw8.server.IResponseWriter;
- import java.nio.ByteBuffer;
- import java.nio.channels.SocketChannel;
- public class ResponseWriter implements IResponseWriter {
- @Override
- public void accept(IResponse t) throws Exception {
- SocketChannel client = t.getClient();
- String responseData = t.getResponseData();
- ByteBuffer buffer = ByteBufferUtil.stringToByteBuffer(responseData);
- while (buffer.hasRemaining()) {
- client.write(buffer);
- }
- client.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement