KickJava   Java API By Example, From Geeks To Geeks.

Java > Java SE, EE, ME > javax > microedition > io > HttpConnection

javax.microedition.io
Interface HttpConnection

All Superinterfaces:
Connection, ContentConnection, InputConnection, OutputConnection, StreamConnection
See Also:
Top Examples, Source Code

public static final String GET
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[268]Read a HTML page
By Anonymous on 2003/06/04 06:58:12  Rate
HttpConnection conn =  ( HttpConnection )  Connector.open ( someUrl ) ; 
     try  {  
       int length =  ( int )  conn.getLength (  ) ; 
       byte [  ]  bytes = new byte [ length ] ; 
       DataInputStream dis = new DataInputStream ( conn.openInputStream (  )  ) ; 
       dis.readFully ( bytes ) ; 
       return Image.createImage ( bytes, 0, bytes.length ) ; 
      }  
     finally  {  
       conn.close (  ) ; 
      }  
 


public long getDate()
             throws IOException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1913]
By iqueen on 2007/08/06 22:17:03  Rate
private static final int RETRY = 3; 
  
  
     /** 
      * open a Connection by given URL, retry 3 times 
      *  
      * @param URL 
      * a String of a URL 
      * @return Connection or null 
      */
 
     private static Connection openConnection ( String URL )   {  
         Connection cnn = null; 
         for  ( int i = 0; i  <  RETRY; i++ )   {  
             try  {  
                 cnn = Connector.open ( URL ) ; 
                 break; 
                  
              }  catch  ( ConnectionNotFoundException e )   {  
                 // ignored, keep retrying 
              }  catch  ( IOException e )   {  
                 // TODO Auto-generated catch block 
                 e.printStackTrace (  ) ; 
              }  catch  ( SecurityException e )   {  
                 break; 
              }  
          }  
         return cnn; 
      }  
  
  
     public static HttpConnection openHttpConnection ( String URL )   {  
         return openHttpConnection ( URL, null ) ; 
      }  
  
  
     /** 
      * open a HttpConnection by given URL and method 
      *  
      * @param URL 
      * a string of URL 
      * @param method 
      * a string of request method 
      * @return an object of HttpConnection or null 
      */
 
     public static HttpConnection openHttpConnection ( String URL, String method )   {  
         Connection connection = openConnection ( URL ) ; 
         HttpConnection httpConnection = null; 
          
         httpConnection =  ( HttpConnection )  connection; 
          
         if  ( method != null )   {  
             try  {  
                 httpConnection.setRequestMethod ( method ) ; 
              }  catch  ( IOException e )   {  
                 // TODO Auto-generated catch block 
                 e.printStackTrace (  ) ; 
              }  
          }  
         return httpConnection; 
      } 


public long getExpiration()
                   throws IOException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public String getFile()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public String getHeaderField(int n)
                      throws IOException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public String getHeaderField(String name)
                      throws IOException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public long getHeaderFieldDate(String name,
                               long def)
                        throws IOException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public int getHeaderFieldInt(String name,
                             int def)
                      throws IOException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public String getHeaderFieldKey(int n)
                         throws IOException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public String getHost()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public long getLastModified()
                     throws IOException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public int getPort()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public String getProtocol()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public String getQuery()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public String getRef()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public String getRequestMethod()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public String getRequestProperty(String key)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public int getResponseCode()
                    throws IOException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public String getResponseMessage()
                          throws IOException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public String getURL()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final String HEAD
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int HTTP_ACCEPTED
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int HTTP_BAD_GATEWAY
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int HTTP_BAD_METHOD
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int HTTP_BAD_REQUEST
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int HTTP_CLIENT_TIMEOUT
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int HTTP_CONFLICT
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int HTTP_CREATED
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int HTTP_ENTITY_TOO_LARGE
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int HTTP_EXPECT_FAILED
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int HTTP_FORBIDDEN
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int HTTP_GATEWAY_TIMEOUT
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int HTTP_GONE
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int HTTP_INTERNAL_ERROR
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int HTTP_LENGTH_REQUIRED
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int HTTP_MOVED_PERM
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int HTTP_MOVED_TEMP
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int HTTP_MULT_CHOICE
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int HTTP_NOT_ACCEPTABLE
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int HTTP_NOT_AUTHORITATIVE
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int HTTP_NOT_FOUND
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int HTTP_NOT_IMPLEMENTED
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int HTTP_NOT_MODIFIED
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int HTTP_NO_CONTENT
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int HTTP_OK
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int HTTP_PARTIAL
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int HTTP_PAYMENT_REQUIRED
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int HTTP_PRECON_FAILED
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int HTTP_PROXY_AUTH
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int HTTP_REQ_TOO_LONG
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int HTTP_RESET
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int HTTP_SEE_OTHER
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int HTTP_TEMP_REDIRECT
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int HTTP_UNAUTHORIZED
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int HTTP_UNAVAILABLE
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int HTTP_UNSUPPORTED_RANGE
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int HTTP_UNSUPPORTED_TYPE
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int HTTP_USE_PROXY
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int HTTP_VERSION
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final String POST
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setRequestMethod(String method)
                      throws IOException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setRequestProperty(String key,
                               String value)
                        throws IOException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  

Popular Tags