Package java.net

Examples of java.net.URLConnection$DefaultContentHandler


    return null;
  }

  private InputStream openStreamForLocalUrl(final String localUrl) throws MalformedURLException, IOException {
    URL url = new URL("http://" + mConfig.getDreamboxAddress() + localUrl);
    URLConnection connection = url.openConnection();

    // set user and password
    String userpassword = mConfig.getUserName() + ":" + mConfig.getPassword();
    String encoded = new String(Base64.encodeBase64(userpassword.getBytes()));
    connection.setRequestProperty("Authorization", "Basic " + encoded);

    // set timeout
    connection.setConnectTimeout(mConfig.getTimeout());
    InputStream stream = connection.getInputStream();
    return stream;
  }
View Full Code Here


     */
    public TreeMap<String, String> getServiceDataBonquets(String service) {
        try {
            URL url = new URL("http://" + mProperties.getProperty("ip","") + "/web/getservices?bRef=" + service);

            URLConnection connection = url.openConnection();

            String userpassword = mProperties.getProperty("username", "") + ":" + IOUtilities.xorEncode(mProperties.getProperty("password", ""), DreamboxSettingsPanel.PASSWORDSEED);
            String encoded = new String(Base64.encodeBase64(userpassword.getBytes()));
            connection.setRequestProperty("Authorization", "Basic " + encoded);

            connection.setConnectTimeout(10);
            InputStream stream = connection.getInputStream();

            SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();

            DreamboxHandler handler = new DreamboxHandler();

View Full Code Here

     * @return Data of specific service
     */
    public TreeMap<String, String> getServiceData(String service) {
        try {
            URL url = new URL("http://" + mProperties.getProperty("ip", "") + "/web/getservices?sRef=" + service);
            URLConnection connection = url.openConnection();

            String userpassword = mProperties.getProperty("username", "") + ":" + IOUtilities.xorEncode(mProperties.getProperty("password", ""), DreamboxSettingsPanel.PASSWORDSEED);
            String encoded = new String(Base64.encodeBase64(userpassword.getBytes()));
            connection.setRequestProperty("Authorization", "Basic " + encoded);

            connection.setConnectTimeout(10);
            InputStream stream = connection.getInputStream();

            SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();

            DreamboxHandler handler = new DreamboxHandler();

View Full Code Here

    private void getEPGData(TvDataUpdateManager updateManager, Channel ch) {
        try {
            URL url = new URL("http://" + mProperties.getProperty("ip", "") + "/web/epgservice?sRef=" + StringUtils.replace(StringUtils.replace(ch.getId().substring(5), "_", ":"), " ", "%20"));

            URLConnection connection = url.openConnection();

            String userpassword = mProperties.getProperty("username", "") + ":" + IOUtilities.xorEncode(mProperties.getProperty("password", ""), DreamboxSettingsPanel.PASSWORDSEED);
            String encoded = new String(Base64.encodeBase64(userpassword.getBytes()));
            connection.setRequestProperty("Authorization", "Basic " + encoded);

            connection.setConnectTimeout(60);
            InputStream stream = connection.getInputStream();

            SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();

            DreamboxChannelHandler handler = new DreamboxChannelHandler(updateManager, ch);
View Full Code Here

   *           If the device could not be contacted
   */
  private StringBuffer readDeviceData(String page) throws TopfieldConnectionException {
    try {
      URL deviceURL = configuration.getDeviceURL(page);
      URLConnection connection = deviceURL.openConnection();
      connection.setConnectTimeout(configuration.getConnectionTimeout());
      InputStream contentStream = (InputStream) connection.getContent();
      BufferedReader in = new BufferedReader(new InputStreamReader(contentStream));
      StringBuffer content = new StringBuffer();
      String line;
      while ((line = in.readLine()) != null) {
        content.append(line);
View Full Code Here

              .get(Calendar.MONTH) + 1, recordStart.get(Calendar.YEAR), recordStart.get(Calendar.HOUR_OF_DAY),
              recordStart.get(Calendar.MINUTE), recordTime.getLength() / 60, recordTime.getLength() % 60);
        }

        URL deviceURL = configuration.getDeviceURL(INSERT_TIMER_PAGE);
        URLConnection connection = deviceURL.openConnection();
        connection.setConnectTimeout(configuration.getConnectionTimeout());
        connection.setDoOutput(true);
        OutputStreamWriter connectionWriter = new OutputStreamWriter(connection.getOutputStream());
        connectionWriter.write(request);
        connectionWriter.close();
        InputStream contentStream = connection.getInputStream();
        BufferedReader in = new BufferedReader(new InputStreamReader(contentStream));
        boolean insertOK = true;
        String line;
        while ((line = in.readLine()) != null) {
          if (line.contains(REPLY_ALERT)) {
View Full Code Here

   */
  public boolean deleteRecording(Window parent, TopfieldTimerEntry entry) throws TopfieldConnectionException {
    String request = String.format(DELETE_FORMAT, entry.getEntryNumber());
    try {
      URL deviceURL = configuration.getDeviceURL(DELETE_TIMER_PAGE);
      URLConnection connection = deviceURL.openConnection();
      connection.setConnectTimeout(configuration.getConnectionTimeout());
      connection.setDoOutput(true);
      OutputStreamWriter connectionWriter = new OutputStreamWriter(connection.getOutputStream());
      connectionWriter.write(request);
      connectionWriter.close();
      // No need to check the answer, it's always OK. Nevertheless we have to
      // read the result or the server on the device won't answer the next
      // request.
      InputStream contentStream = connection.getInputStream();
      BufferedReader in = new BufferedReader(new InputStreamReader(contentStream));
      while (in.readLine() != null) {
        ;
      }
      in.close();
View Full Code Here

* if any changes have been made from this point on.
*
* @param fileName a file name
*/
protected void writeReportFile(String fileName) {
    URLConnection conn = null;

    try {
  URL url = new URL(fileName);
  conn = url.openConnection();
  conn.setDoOutput(true);

  sendData(conn);
  // I don't know why, but we have to read the response from the
  // server, even if it's empty.
  receiveResponse(conn);
View Full Code Here

        new ApplicationServerHandler(rootNode, "/application"),
        serverBinding);
    URL serverURL = new URL("http://"
        + serverBinding.getInetAddress().getHostAddress() + ":"
        + serverBinding.getPort() + "/application/test-dir/test-data");
    URLConnection connection = serverURL.openConnection();
    String contentType = connection.getHeaderField("Content-Type");
    assertEquals("text/plain", contentType);
    webServer.stop();

  }
View Full Code Here

        downloadInternal(address, destination);
    }

    private void downloadInternal(String address, File destination) throws Exception {
        OutputStream out = null;
        URLConnection conn;
        InputStream in = null;
        try {
            URL url = new URL(address);
            out = new BufferedOutputStream(
                    new FileOutputStream(destination));
            conn = url.openConnection();
            in = conn.getInputStream();
            byte[] buffer = new byte[BUFFER_SIZE];
            int numRead;
            long progressCounter = 0;
            while ((numRead = in.read(buffer)) != -1) {
                progressCounter += numRead;
View Full Code Here

TOP

Related Classes of java.net.URLConnection$DefaultContentHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.