1

How do i make java read this php file. this php file should be read from it url: http://www.example.com/my/php/doc.php (this is not the real url)

//from http://www.example.com/my/php/doc.php

<?php  
echo($strServer);
echo($strUrl);
echo($strdbName);
echo($strdbUser);
echo($strdbPass);;
echo($Name);
?>

by using java application it should be able to read php echo and display in netbean. I hope my explanation is brief and simple enough. any idea everybody

Learner
  • 101
  • 3
  • 15
  • possible duplicate of [How do I retrieve a URL from a web site using Java?](http://stackoverflow.com/questions/359439/how-do-i-retrieve-a-url-from-a-web-site-using-java) ... and hundreds of others like it. Note there is nothing *special* about a PHP server ... – Stephen C Jan 27 '14 at 07:34

1 Answers1

5

Official tutorial, found by ... googling: http://docs.oracle.com/javase/tutorial/networking/urls/readingURL.html

import java.net.*;
import java.io.*;

public class URLReader {
    public static void main(String[] args) throws Exception {

        URL oracle = new URL("http://www.oracle.com/");
        BufferedReader in = new BufferedReader(
        new InputStreamReader(oracle.openStream()));

        String inputLine;
        while ((inputLine = in.readLine()) != null)
            System.out.println(inputLine);
        in.close();
    }
}
Xabster
  • 3,710
  • 15
  • 21