本帖最后由 陈琦 于 2012-10-30 11:55 编辑
- <div class="blockcode"><blockquote>public class InterTest {
- public static void main(String[] args) throws Exception {
- ServerSocket ss = new ServerSocket(8888);
- Socket s = ss.accept();
- InputStream in = s.getInputStream();
- int len = 0;
- byte b[] = new byte[1024];
- while((len=in.read(b))!=-1) {
- System.out.print(new String(b,0,len));
- //System.out.print(new String(b,0,b.length)); 另外这两句应该一样吧
- }
- OutputStream out = s.getOutputStream();
- PrintWriter pw = new PrintWriter(out,true);
- pw.println("<font size=\"20\" color=\"red\">你大爷</font>");
- pw.close();
- s.close();
- ss.close();
- }
- }
复制代码 |