Announcement

Collapse
No announcement yet.

Android Fehlermeldung java.io.FileNotFoundException

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Android Fehlermeldung java.io.FileNotFoundException

    Guten Abend,

    meine Androit Testactivity zum Testen meines PHP-Scriptes schreibt mit immer folgende Fehlermeldung

    Code:
    W/System.err: java.io.FileNotFoundException: [Link+GET-Parameter]
    W/System.err:     at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:250)
    W/System.err:     at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getInputStream(DelegatingHttpsURLConnection.java:210)
    W/System.err:     at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java)
    W/System.err:     at testconnect.MainActivity$4.run(MainActivity.java:152)
    W/System.err:     at java.lang.Thread.run(Thread.java:761)
    Klicke ich allerdings auf den Link, liefert das Script mir das gewünschte Ergebnis.

    Vielen Dank im Vorraus.

    Quellcode der Funktion:

    Code:
    private void requestFromServer() {
    new Thread(new Runnable() {
         @Override
    public void run() {
              try {
                    URL scriptURL = new URL(internetURL);
                    HttpURLConnection connection = (HttpURLConnection) scriptURL.openConnection();
                    connection.setDoOutput(false);
                    connection.setRequestMethod("GET");
                    connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
                    connection.setRequestProperty("Content-Type", "application/json");
                    String authorization = username + ":" + password;
                    byte[] encodedBytes = Base64.encode(authorization.getBytes(), 0);
                    authorization = "Basic " + encodedBytes;
                    connection.setRequestProperty("Autorization", authorization);
                    InputStream answerInputStream = connection.getInputStream();
                    final String answer = getTextFromInputstream(answerInputStream);
                    runOnUiThread(new Runnable() {
                        @Override
    public void run() {
                            tv.setText(answer);
                        }
                    });
                    answerInputStream.close();
                    connection.disconnect();
              } catch (MalformedURLException e) {
                    e.printStackTrace();
              } catch (IOException e) {
                    e.printStackTrace();
              }
         }
    }).start();
    }
    Zuletzt editiert von Earth; 29.04.2019, 00:11.

  • #2

    internetURL dürfte wohl falsch sein
    Christian

    Comment


    • #3
      Originally posted by Earth View Post
      Klicke ich allerdings auf den Link, liefert das Script mir das gewünschte Ergebnis.
      dann frage ich mich, wie das möglich ist..?

      Comment


      • #4
        Zeige, was die Variable für einen Inhalt hat, debugge dein Programm
        Christian

        Comment


        • #5
          genau den Link, den ich möchte

          Comment

          Working...
          X