[問題] 請問一個輸入的問題
請問我想要鍵盤鍵入後
馬上將這個字元傳到outputstream去
並且不要在螢幕上顯示
這樣我從鍵盤來的input要怎麼寫啊?
outputstream取得的方法用write()可以吧?
我想要從bbs上取資料 讀的部份ok
但不知該怎麼傳資料給bbs
另外就是 方向鍵的問題 不知該怎麼解決
(不過有其他鍵可以取代 沒解決也沒關係)
附上程式碼
import java.io.*;
import java.net.*;
//開個socket接收/傳送資料至bbs,接收和傳送要放在兩個不同的threads
class BBSsend extends Thread{
OutputStream os;
//constructor
BBSsend(Socket socket) throws Exception{
os=socket.getOutputStream();
}
public void run(){
try{
while(true){
os.write(new BufferedReader(
new InputStreamReader(System.in)).read());
} //↑這邊搞好久都搞不定...拜託了
} catch (Exception e){}
}
}
public class BBS{
public static void main(String[] args) throws Exception{
String server="ptt.cc";
Socket socket=new Socket(server,23);
BufferedReader br=new BufferedReader(new
InputStreamReader(socket.getInputStream()));
BBSsend send=new BBSsend(socket);
send.start();
while(true){
System.out.println(br.readLine());
}
}
}
--
▄▄ ▄▄ ▄▄▄ ▄ ▄▄▄
▄ ▄ ▄ ▄▄ ▄ ▄▄
▄ ▄ ▄ ▄ ▄▄
▄ ▄ ▄
▄ ▄ ▄ ▄ ▄▄
▄ ▄ ▄▄▄ ▄ ▄ ▄ ▄▄▄▄
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.213.190
※ 編輯: ozone 來自: 140.112.213.190 (01/14 00:41)
推
01/14 02:09, , 1F
01/14 02:09, 1F
→
01/14 02:47, , 2F
01/14 02:47, 2F
→
01/14 02:48, , 3F
01/14 02:48, 3F
推
01/14 03:32, , 4F
01/14 03:32, 4F
→
01/14 03:33, , 5F
01/14 03:33, 5F
推
01/14 23:29, , 6F
01/14 23:29, 6F
→
01/15 12:34, , 7F
01/15 12:34, 7F
推
01/15 23:35, , 8F
01/15 23:35, 8F
→
01/15 23:36, , 9F
01/15 23:36, 9F
→
01/16 01:40, , 10F
01/16 01:40, 10F
→
01/18 04:32, , 11F
01/18 04:32, 11F