Solved

Evaluate of a return Message in Java

Posted on 1997-11-19
2
156 Views
Last Modified: 2012-05-04
When I input the URL http://cameraname/io/relayon.txt in a Browser, I can switch on the relay in a camera web server. The server then gives the back the Message Relay is on that I can see in the Browser. My question is, how can I evaluate  
this Message in Java? Maybe with InputStream or DataInputStream or FileInputStream or otherwise?
I've tried it like this, but it does not work:

URL urlOpen = new URL(http://cameraname/io/relayon.txt);
URLConnection connect = urlOpen.openConnection();
connect.setDefaultAllowUserInteraction( true);
connect.setUseCaches( false );      
connect.setDoInput( true );            
connect.setDoOutput( false );       
connect.connect();

DataInputStream inputstream = new DataInputStream( connect.getInputStream()      );
                  
while( (String s=inputstream.readLine()) != null );
{
      // do whatever you want to do with s
}
inputstream.close();

Thanks, Mike
0
Comment
Question by:mkaufman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 4

Accepted Solution

by:
rembo earned 20 total points
ID: 1230935

You were close:

DataInputStream dis;

URL urlOpen = new URL(http://cameraname/io/relayon.txt);

dis = new DataInputStream(urlOpen.openStream());

String s;

while ((s = dis.readLine()) != null) {
  System.out.println(s);
  //Or whatever it is you do :)
}
0
 

Author Comment

by:mkaufman
ID: 1230936
I've tried it but it does not work.
The String s is always empty. Have I maybe to wait a moment to the answer from the server?
Then I could wait for it in a Thread.

Thank Mike

0

Featured Post

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question