简体   繁体   中英

how to read php echo statement using java

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

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();
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM