Jump to content

Java equivalent of PHP code


dontknowmuch
 Share

Recommended Posts

my java is very rusty and I have nowhere to test this out but I hope it at least points you in the right direction

//equivalent of //$html = file_get_contents("http://www.google.com/index.html");String html = "";InputStream in = null;try {	in = new BufferedInputStream		(new FileInputStream(root + "/message.txt") );	int ch;	while ((ch = in.read()) !=-1) {		html += String.valueOf((char)ch);	}}finally {	if (in != null) in.close();  // very important}//echo "html: <br>" . nl2br(htmlentities($html));OutputStream out = response.getOutputStream();out.write(html);

quite a bit to replace 2 php lines huh?

Link to comment
Share on other sites

  • 3 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...