Olá…
Estou criando um Serversinho que está escutando a porta 8011, acesso pelo Browser.
Por exemplo http://localhost:8011/pasta/arquivo.html
Eu gostaria de pegar o fianl da string “/pasta/arquivo.html”, assim eu retorno o arquivo desejado…
Abaixo o metodo run da minha thread que irá processar a requisição:
public void run() {
try {
BufferedReader read =
new BufferedReader(new InputStreamReader(
socket.getInputStream()));
while(read.ready()){
System.out.println( read.readLine());
}
socket.close();
} catch (IOException ex) {
Logger.getLogger(ThreadSocket.class.getName()).log(Level.SEVERE, null, ex);
}
}
Abaixo o conteúdo que chega:
GET /site HTTP/1.1
Host: localhost:8011
User-Agent: Mozilla/5.0 (X11; U; Linux i686; pt-BR; rv:1.9.2.6) Gecko/20100628 Ubuntu/10.04 (lucid) Firefox/3.6.6
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: pt-br,pt;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
se alguém poder me ajudar