package edu.kaist.mrlab.srdf.tools;

import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.Socket;

public class KoreanAnalyzer {
	private Socket soc;

	public String getResult(String input) throws Exception {
		StringBuffer sb = new StringBuffer();

		InetAddress ia = null;

		String serverIp = "143.248.135.60";

		try {
			ia = InetAddress.getByName(serverIp);
			soc = new Socket(ia, 10110);

			OutputStream os = soc.getOutputStream();
			BufferedOutputStream bos = new BufferedOutputStream(os);

			bos.write((input).getBytes()); 
			bos.flush();
			soc.shutdownOutput();
			
			InputStream is = soc.getInputStream();
			InputStreamReader isr = new InputStreamReader(is);
			BufferedReader br = new BufferedReader(isr);

			String line = null;
			while (true) {
				line = br.readLine();
				if (line == null)
					break;
				line = line.trim();
				if (line.equals(""))
					continue;

				sb.append(line);
				sb.append("\n");
			}
			bos.close();
			br.close();

		} catch (Exception e) {
			// e.printStackTrace();
			throw e;
		}

		return sb.toString();
	}

	public static void main(String[] args) {
		KoreanAnalyzer ex = new KoreanAnalyzer();
		
		try {
			String output = ex.getResult("세종대왕은 한자를 모르는 민중을 위해 한글을 창제하였다.");
			System.out.println(output);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
@@ -457,9 +457,9 @@
 135.
-6
+2
 0%22;%0A
@@ -536,13 +536,13 @@
 ia, 
-10110
+22334
 );%0A%0A
@@ -1506,8 +1506,9 @@
 %09%09%7D%0A%09%7D%0A%7D
+%0A

Update KoreanAnalyzer.java