• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 160
  • Last Modified:

Evaluate of a return Message in Java

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
mkaufman
Asked:
mkaufman
1 Solution
 
remboCommented:

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
 
mkaufmanAuthor Commented:
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now