當前位置: 首頁>>代碼示例>>Python>>正文


Python io.BufferedReader方法代碼示例

本文整理匯總了Python中java.io.BufferedReader方法的典型用法代碼示例。如果您正苦於以下問題:Python io.BufferedReader方法的具體用法?Python io.BufferedReader怎麽用?Python io.BufferedReader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.io的用法示例。


在下文中一共展示了io.BufferedReader方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: view_source

# 需要導入模塊: from java import io [as 別名]
# 或者: from java.io import BufferedReader [as 別名]
def view_source(context, web_view, filename):
    from base64 import b64encode
    from os.path import join
    from pygments import highlight
    from pygments.formatters import HtmlFormatter
    from pygments.lexers import get_lexer_for_filename

    from java.io import BufferedReader, InputStreamReader

    stream = context.getAssets().open(join(ASSET_SOURCE_DIR, filename))
    reader = BufferedReader(InputStreamReader(stream))
    text = "\n".join(iter(reader.readLine, None))

    formatter = HtmlFormatter()
    body = highlight(text, get_lexer_for_filename(filename), formatter)
    html = ("<html><head><style>{}\n{}</style></head><body>{}</body></html>"
            .format(formatter.get_style_defs(), EXTRA_CSS, body)).encode()
    web_view.loadData(b64encode(html).decode(), "text/html", "base64") 
開發者ID:chaquo,項目名稱:chaquopy,代碼行數:20,代碼來源:ui_demo.py

示例2: run

# 需要導入模塊: from java import io [as 別名]
# 或者: from java.io import BufferedReader [as 別名]
def run(self):
        try:
            while (self.inStream.read() != -1):
                isr = InputStreamReader(self.inStream)
                br = BufferedReader(isr)
                print str(br.readLine())

        except BaseException as ex:
            print 'Could not read API input/output/error buffer\n' 
開發者ID:codewatchorg,項目名稱:sqlipy,代碼行數:11,代碼來源:SQLiPy.py

示例3: _excmd

# 需要導入模塊: from java import io [as 別名]
# 或者: from java.io import BufferedReader [as 別名]
def _excmd(self, sshcmd):
        '''
        return (connected_ok, response_array)
        '''        
        connected_ok=True
        resp = []        
        try:
            conn = Connection(self.hostname)
            conn.connect()
            self.logger.info('ssh connection created.')
            isAuthenticated = conn.authenticateWithPassword(self.user, self.password)
            if not isAuthenticated:
                connected_ok=False
                self.logger.error('ssh failed to authenticatd.')
            else:
                self.logger.info('ssh authenticated.')
                sess = conn.openSession()
                
                self.logger.info('ssh session created.')
                sess.execCommand(sshcmd)
                self.logger.info('ssh command issued. cmd is %s'%sshcmd)
    
                stdout = StreamGobbler(sess.getStdout())
                br = BufferedReader(InputStreamReader(stdout))
                while True:
                    line = br.readLine()
                    if line is None:
                        break
                    else :
                        resp.append(line)
                self.logger.warning('ssh command output: '%resp)
        except IOException ,ex:
            connected_ok=False
            #print "oops..error,", ex            
            self.logger.error('ssh exception: %s'% ex) 
開發者ID:harryliu,項目名稱:edwin,代碼行數:37,代碼來源:__init__.py

示例4: _stringio_as_reader

# 需要導入模塊: from java import io [as 別名]
# 或者: from java.io import BufferedReader [as 別名]
def _stringio_as_reader(s):
    return BufferedReader(InputStreamReader(ByteArrayInputStream(bytearray(s.getvalue())))) 
開發者ID:Acmesec,項目名稱:CTFCrackTools-V2,代碼行數:4,代碼來源:_sslcerts.py


注:本文中的java.io.BufferedReader方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。