Ho il codice:
Domanda: per evitare di inviare e parsare gli header HTTP, che metodi posso usare "più ad alto livello"?codice:public String prepareAttachments(long idDoc) { String line = null; try { Socket s = new Socket("localhost", 80); try { Scanner in = new Scanner(s.getInputStream()); PrintWriter out = new PrintWriter(s.getOutputStream()); // Invio. out.print("GET /test.php?idDoc="+idDoc+" HTTP/1.1\r\n"); out.print("Accept: text/html\r\n"); out.print("Host: localhost\r\n"); out.print("Connection: Close\r\n"); out.print("\r\n"); out.flush(); // Ricevo. while (in.hasNextLine()) { line += in.nextLine(); } } finally { s.close(); } } catch (IOException e) { e.printStackTrace(); } return line; }
Grazie.

Rispondi quotando