java detect network connection status

2010-11-09  来源:本站原创  分类:Java  人气:85 

public static void main(String[] args) {
                URL url = null;
                try {
                        url = new URL("http://baidu.com");
                        try {
                                InputStream in = url.openStream();
                                in.close();
                                System.out.println(" Network connectivity  !");
                        } catch (IOException e) {
                                System.out.println(" Network connection fails  !");
                        }
                } catch (MalformedURLException e) {
                        e.printStackTrace();
                }
        }
相关文章
  • java detect network connection status 2010-11-09

    public static void main(String[] args) { URL url = null; try { url = new URL("http://baidu.com"); try { InputStream in = url.openStream(); in.close(); System.out.println(" Network connectivity !"); } catch (IOException e) { System.out.

  • View Network connection status 2010-09-28

    View Network connection status netstat-na Screening, the number of rows of Statistics | Grep ESTAB | grep 80 | wc-l

  • Phone network connection status monitoring 2010-07-29

    Up early in the morning, sleep. Android phone most of the support WIFI, GSM, 3G network, but can only use each time you connect the network certainly one of them. Some programs (such as: custom operators) must also require the use of specific network

  • Detect network connection 2010-12-27

    /* * isOnline - Check if there is a NetworkConnection * @return boolean */ protected boolean isOnline() { ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netInfo = cm.getActiveNetworkInfo();

  • Comparing Java framework database connection pool (c3p0, dbcp and proxool) 2011-07-16

    Now commonly used open source data connection pool are c3p0, dbcp and proxool three, including: ¨ hibernate team recommends using c3p0; ¨ spring team recommends using dbcp (dbcp connection pool weblogic connection pool has the same problem, is forced

  • (R) JAVA detect whether the network connectivity status ping 2011-03-23

    Java detect whether to use network resources available, we can use the following two methods: One way is to call the ping command, Such as: Process process = Runtime.getRuntime (). Exec ("ping 192.168.0.5"); InputStreamReader return = new InputS

  • java detect the availability of network resources, two approaches 2010-07-25

    Java detect whether to use network resources available, we can use the following two methods: One way is to call the ping command, Such as: Process process = Runtime.getRuntime (). Exec ("ping 192.168.0.5"); InputStreamReader return = new InputS

  • C3P0 Error: java.sql.SQLException: Connection is invalid 2010-03-29

    2010-02-20 11:01:16,093 WARN [com.mchange.v2.async.ThreadPoolAsynchronousRunner] -- com.mchange.v2.async.ThreadPoolAsynchronousRunner $ DeadlockDetector @ 16a3360 - APPARENT DEADLOCK!!! Creating emergency threads for unassigned pending tasks! 2010-02

  • java.net.ConnectException: Connection refused: connect 2010-04-14

    Socket exception with the exception MINA Socket Exception Client Exception java.net.ConnectException: Connection refused: connect. The exception occurs on the client for new Socket (ip, port) operation, the exception occurs because the ip address or

  • java.net.SocketException: Connection reset 2010-06-11

    java.net.SocketException: Connection reset at java.net.SocketInputStream.read (SocketInputStream.java: 168) at java.io.BufferedInputStream.read1 (BufferedInputStream.java: 256) at java.io.BufferedInputStream.read (BufferedInputStream.java: 317) at ja

  • Check the network connection 2010-07-23

    Check whether the network connection /** * Detect network is connected ( Note : Need to profile the permission to join the AndroidManifest.xml ) * * @param context * @return true : Network connection successful * @return false : Network connection fa

  • Java common network communication error summary --TCP/IP 2010-08-01

    Java pitfalls and network traffic analysis --TCP/IP 1. IP error, port error, port is occupied Scenario occurred: two clients at the same time to connect with a server Analysis: multi-threaded server is not turned on the corresponding link to the clie

  • View all ports netstat network connection 2011-05-16

    Function: Netstat to display IP, TCP, UDP and ICMP protocol-related statistics are generally used for testing the machine's network connections on each port. Syntax: netstat [-acCeFghilMnNoprstuvVwx] [-A <Network Type >][-- ip] Additional informatio

  • View the local IP connection status 2011-03-09

    View the local IP connection status In the 'Run', enter cmd Into the prompt, enter netstat-a-n Then it will show 2, No. 2 is already connected to your computer's IP 127.0.0.1 is your computer Once every 5 seconds to display active TCP connections and

  • HttpClient to resume after the local network, connection, or the solution will be thrown 2010-04-02

    HttpClient to resume after the local network, connection or will it throw the exception

  • Set the network connection to install VirtualBox 2010-04-25

    After the success of installing VirtualBox will appear in the network connection in "VirtualBox Host-Only Network" connection. This is because the installation of the Network Interface of the reasons, the connection point "Properties"

  • c3p0 java.sql.SQLException: Connection is invalid solution 2010-06-14

    Written in the past few days found himself idle for a web program will throw a similar exception. [Com.mchange.v2.async.ThreadPoolAsynchronousRunner $ PoolThread-# 1] (BasicResourcePool.java: 1407) WARN com.mchange.v2.resourcepool.BasicResourcePool -

  • J2ME network connection 2010-08-13

    In J2ME, many applications have to deal with the server, which involves the network connection. At present two ways of connecting mobile open network: 1.1 cmnet, the easier to understand, with no difference between Internet computers. Directly with t

  • java.net.SocketException: Connection reset problem solving 2010-11-11

    java.net.SocketException: Connection reset problem solving client connection with a long connection, that is, write a loop, while ture; with while ((temp = inputStream.read (buffer))! = -1) { System.out.println (new String (buffer, 0, temp)); } Will

  • jps (Java Virtual Machine Process Status Tool) 2010-11-26

    jps (Java Virtual Machine Process Status Tool) is a JDK 1.5 provides all the java process shows the current pid of the command, simple and practical for the linux / unix platform, a simple look at the current situation of some simple java process. jp