欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

php-PHP转Java该怎么实现,请大神帮忙

程序员文章站 2024-02-13 20:54:46
...
php
protected function _postWithCookie($uri, $data){    $fp = fsockopen('f.10086.cn', 80);    fputs($fp, "POST $uri HTTP/1.1\r\n");    fputs($fp, "Host: f.10086.cn\r\n");    fputs($fp, "Cookie: {$this->_cookie}\r\n");    fputs($fp, "Content-Type: application/x-www-form-urlencoded\r\n");    fputs($fp, "User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:14.0) Gecko/20100101 Firefox/14.0.1\r\n");    fputs($fp, "Content-Length: ".strlen($data)."\r\n");    fputs($fp, "Connection: close\r\n\r\n");    fputs($fp, $data);    $result = '';    while (!feof($fp))    {        $result .= fgets($fp);    }    fclose($fp);    return $result;}

这段代码用Java怎么实现

相关标签: php