Jump to content
Sign in to follow this  
dontknowmuch

Java equivalent of PHP code

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?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...