801

Как закодить в C# java примерчик

public void VerHttpServer() { int port = 80; URL wh,u; String AdrVer,GetStringWebI=""; u = getCodeBase(); //HEAD /Default.htm HTTP/1.0//Connection: Close//User-Agent: Mozilla/4.05 (WinNT; 1)//Host: www.ora.com Accept: image/gif AdrVer = u.toString()+"WebInterrogation.txt"; try { wh = new URL(AdrVer); } catch (MalformedURLException e) { wh = null; return; } if (wh!=null){ try { BufferedReader is = new BufferedReader(new InputStreamReader(wh.openStream())); String fromHome; while ((fromHome = is.readLine()) != null) { GetStringWebI += fromHome + ''\n''; } is.close(); } catch (Exception e) { System.out.println("CONNECTION_ERROR"); return; } } try {// textField1.getText() http server url Socket kkSocket = new Socket(textField1.getText(),port); PrintWriter os = new PrintWriter(kkSocket.getOutputStream()); BufferedReader is = new BufferedReader(new InputStreamReader(kkSocket.getInputStream())); String fromServer; os.println(GetStringWebI); os.println(""); os.println(""); os.flush(); while ((fromServer = is.readLine()) != null) { System.out.println(fromServer); } os.close(); is.close(); kkSocket.close(); } catch (UnknownHostException e) { System.out.println("UNKNOWN_HOST"); } catch (Exception e) { e.printStackTrace(); }}
0