当前位置: 首页>>代码示例>>Python>>正文


Python String.length方法代码示例

本文整理汇总了Python中java.lang.String.length方法的典型用法代码示例。如果您正苦于以下问题:Python String.length方法的具体用法?Python String.length怎么用?Python String.length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.lang.String的用法示例。


在下文中一共展示了String.length方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: JythonJavaHttpRequest

# 需要导入模块: from java.lang import String [as 别名]
# 或者: from java.lang.String import length [as 别名]

#.........这里部分代码省略.........
        
        """
        if not self.__request_uri_str:
            self.__request_uri_str = self.__native_req.getRequestURI().toString()
        return self.__request_uri_str
    
    def getRequestPath(self):
        """
        Return only the path component of the URI.
        
        @return:    The path component of the URI.
        @rtype:     string
        
        """
        return self.__native_req.getRequestURI().getPath()
    
    def getRequestHeaders(self):
        """
        Return a dictionary with the request headers.
        
        Each header can have multiple entries, so this is a
        dictionary of lists.
        
        @return:    Dictionary containing a list of values for each header.
        @rtype:     dict
        
        """
        if not self.__request_headers:
            self.__request_headers = dict(self.__native_req.getRequestHeaders())
        return self.__request_headers
    
    def getRequestQuery(self):
        """
        Return only the query component of the URI.
        
        @return:    Query portion of the URI (the part after the first '?').
        @rtype:     string
        
        """
        return self.__native_req.getRequestURI().getQuery()
    
    def getRequestBody(self):
        """
        Return the body of the request message.
        
        Note that this is not very suitable for streaming or large message bodies
        at this point, since the entire message is read into a single string
        before it is returned to the client.
        
        @return:    Body of the request.
        @rtype:     string
        
        """
        buffered_reader = BufferedReader(InputStreamReader(self.__native_req.getRequestBody()));
        lines = []
        while True:
            line = buffered_reader.readLine()
            if not line:
                break
            lines.append(line)
        
        return '\n'.join(lines)
    
    def sendResponseHeaders(self):
        """
        Send the previously specified response headers and code.
        
        """
        response_headers = self.__native_req.getResponseHeaders()
        for name, value in self.__response_headers.items():
            response_headers[name] = [ value ]
        self.__native_req.sendResponseHeaders(self.__response_code, self.__response_body.length())
    
    def sendResponseBody(self):
        """
        Send the previously specified request body.
        
        """
        os = DataOutputStream(self.__native_req.getResponseBody())
        os.writeBytes(self.__response_body)
        os.flush()
        os.close()
        
    def sendResponse(self):
        """
        Send the previously specified response headers, code and body.
        
        This is the same as calling sendResponseHeaders() and sendResponseBody()
        separately.
        
        """
        self.sendResponseHeaders()
        self.sendResponseBody()
        
    def close(self):
        """
        Close this connection.
        
        """
        self.__native_req.close()  
开发者ID:ddossot,项目名称:glu,代码行数:104,代码来源:jython_java_server.py


注:本文中的java.lang.String.length方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。