?? redirectserver.java
字號:
// 程序:簡單的服務器
// 范例文件:RedirectServer.java
import java.net.*;
import java.io.*;
public class RedirectServer {
public static void main(String args[])
{
try {
ServerSocket sktServer;
Socket sktClient;
PrintStream send;
int count = 0;
sktServer = new ServerSocket(80);
while (true)
{
try {
System.out.println("服務器等待連線");
sktClient = sktServer.accept();
count++;
System.out.println("客戶端連線:" + count);
send = new PrintStream(sktClient.getOutputStream());
send.print("HTTP/1.0 302 FOUND\r\n");
send.print("Location: http://www.acertwp.com.tw\r\n");
sktClient.close();
}
catch (IOException e) {
System.out.println(e.getMessage());
}
}
}
catch (IOException e) {
System.out.println(e.getMessage());
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -