⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 connectiontest.java

📁 the program connects to an URL and retrieves the index.php file content
💻 JAVA
字号:
/*
the program connects to the "http://mercur.utcluj.ro/lab/index.php" URL and retrieves the
index.php file content
*/


import java.net.*;
import java.io.*;

class ConnectionTest {
    public static void main(String args[]) {
        try {
            URL remote_url = new URL("http://mercur.utcluj.ro/lab/index.php");
            URLConnection remote_connection = remote_url.openConnection();
            BufferedReader dis;
	    String inputLine;
	    String server_text = new String();


	    dis = new BufferedReader(new InputStreamReader(remote_connection.getInputStream()));
            while ((inputLine = dis.readLine()) != null) {
                //System.out.println(inputLine);
		server_text += inputLine;
            }
	    dis.close();

		FileOutputStream fisIesire=new FileOutputStream("E://temp.txt");
			
		DataOutputStream dos = new DataOutputStream (fisIesire);
		dos.writeUTF(server_text);
		dos.close();



        } catch (MalformedURLException me) {
            System.out.println("MalformedURLException: " + me);
        } catch (IOException ioe) {
            System.out.println("IOException: " + ioe);
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -