1. Obtain all host IP addresses for the LAN
Ping IP timeout time to wait for each reply:-W 280 number of ECHO requests to send:-N 1
Process process=runtime.getruntime (). EXEC ("ping");
Process.getinputstream ()----inputstreamreader ()----Bufferreader in=new bufferreader ()----String Line=in.readline ( )----line.substring (0,2). Equals ("from") | | -line.substring (0,10). Equals ("Reply from")
Obtain all the IP address of the intranet, first obtain the network segment that the IP address of the machine belongs to, then ping the IP address in the network, read the result of the ping by the input stream object, and determine whether the IP address of the intranet
2. Get the size of a network resource
The new URL (String URL). OpenConnection (). connect (); Open a communication link to a URL reference resource
Urlconnection.getcontentlength () returns the resource size in bytes
3. Multi-threaded download of network resources
1>conn.getinputstream ()----bufferedinputstream (in)----int len=bin.read (buffer)!=1
Byte[] Buffer=new byte[2048]; Out.write (Buffer,0,len);
2>new url (String url). OpenConnection (). Getresponsecode () Get the connection Status tag code
Getcontentlength () disconnect () 200--connection Status
. Setrequestproperty ("User-agent", "Netfox") Set request properties
. Setrequestproperty ("range", "byte=" + "-") Set the request Scope property String File=getfile ()
4. Transferring pictures using the socket
DataInputStream read ()----The picture file to the byte array
DataOutputStream (Inherit dataoutput)----write ()----output byte array
New Serversocket.accept ()----instantiating the socket object
DataInputStream (Socket.getoutputstream ())----Readlong ()/readbyte () DataOutputStream (Socket.getinputstream ())
Client send: New DataInputStream (New FileInputStream (imgfile))----Read (BT)
Out.writelong (Imgfile.length ()) Out.write (BT) new byte[(int) imagefile.length ()]
5.BufferReader reader=new Bufferreader (New InputStreamReader (Socket.getinputstream ()))----String S=reader.readline ()
java--Network Knowledge Accumulation