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


Python FileInputStream.read方法代码示例

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


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

示例1: addFile

# 需要导入模块: from java.io import FileInputStream [as 别名]
# 或者: from java.io.FileInputStream import read [as 别名]
 def addFile(self, file, parentDirName=None):
   buffer = jarray.zeros(self._bufsize, 'b')
   inputStream = FileInputStream(file)
   jarEntryName = file.getName()
   if parentDirName:
     jarEntryName = parentDirName + "/" + jarEntryName
   self.getJarOutputStream().putNextEntry(JarEntry(jarEntryName))
   read = inputStream.read(buffer)
   while read <> -1:
       self.getJarOutputStream().write(buffer, 0, read)
       read = inputStream.read(buffer)
   self.getJarOutputStream().closeEntry()
   inputStream.close()
开发者ID:Britefury,项目名称:jython,代码行数:15,代码来源:support.py

示例2: compareFileHashes

# 需要导入模块: from java.io import FileInputStream [as 别名]
# 或者: from java.io.FileInputStream import read [as 别名]
def compareFileHashes(dxFileName, amFileName, msgId):
    dxFile = FileInputStream(dxFileName)
    dxMsgContentHash = sha.new(str(dxFile.read()))
    dxFile.close()
    amFile = FileInputStream(amFileName)
    amMsgContentHash = sha.new(str(amFile.read()))
    amFile.close()

    if dxMsgContentHash.digest() == amMsgContentHash.digest():
        #print "message has same hash on AM partition and DX", msgId
        printQueue.append("output message " +  str(msgId) + " is present in DX")
        return True
    else:
        printErrorToRemigrate(msgId, " content hash differ on AM partition and DX. dx hash: " + dxMsgContentHash.hexdigest() + " am hash: " + amMsgContentHash.hexdigest())
        return False
开发者ID:piyush76,项目名称:EMS,代码行数:17,代码来源:dx_script_unsorted.py

示例3: add_folder

# 需要导入模块: from java.io import FileInputStream [as 别名]
# 或者: from java.io.FileInputStream import read [as 别名]
def add_folder(zos, folder_name, base_folder_name):
    f = File(folder_name)
    if not f.exists():
        return
    if f.isDirectory():
        for f2 in f.listFiles():
            add_folder(zos, f2.absolutePath, base_folder_name)
        return
    entry_name = folder_name[len(base_folder_name) + 1:len(folder_name)]
    ze = ZipEntry(entry_name)
    zos.putNextEntry(ze)
    input_stream = FileInputStream(folder_name)
    buffer = zeros(1024, 'b')
    rlen = input_stream.read(buffer)
    while (rlen > 0):
        zos.write(buffer, 0, rlen)
        rlen = input_stream.read(buffer)
    input_stream.close()
    zos.closeEntry()
开发者ID:xebialabs-community,项目名称:xld-custom-orchestrators-plugin,代码行数:21,代码来源:xld_initialize.py

示例4: readBinaryFile

# 需要导入模块: from java.io import FileInputStream [as 别名]
# 或者: from java.io.FileInputStream import read [as 别名]
 def readBinaryFile(cls, rootFile):
     """ generated source for method readBinaryFile """
     in_ = FileInputStream(rootFile)
     out = ByteArrayOutputStream()
     #  Transfer bytes from in to out
     buf = [None]*1024
     while in_.read(buf) > 0:
         out.write(buf)
     in_.close()
     return out.toByteArray()
开发者ID:hobson,项目名称:ggpy,代码行数:12,代码来源:LocalGameRepository.py

示例5: test_read_file

# 需要导入模块: from java.io import FileInputStream [as 别名]
# 或者: from java.io.FileInputStream import read [as 别名]
    def test_read_file(self):
        from java.io import FileInputStream
        from java.lang import String

        filename = os.path.join(
            os.path.abspath(os.path.dirname(__file__)),
            'data/read_file.txt')
        fin = FileInputStream(filename)
        ar = jarray(20, JBYTE_ID)
        count = fin.read(ar)
        s = String(ar, 0, count)
        self.assertEqual(str(s).strip(), 'aewrv3v')
开发者ID:Macowe,项目名称:jep,代码行数:14,代码来源:test_array.py

示例6: write

# 需要导入模块: from java.io import FileInputStream [as 别名]
# 或者: from java.io.FileInputStream import read [as 别名]
	def write(self, name, file):
		fp = self.getFile(name)
		if isinstance(file, ByteArrayOutputStream):
			file.writeTo(fp)
		else:
			if isinstance(file, type('')):
				file = FileInputStream(file)
			data = jarray.zeros(1024*4, 'b')
			#print 'writing', file,
			while 1:
				n = file.read(data)
				#print n,
				if n == -1: break
				fp.write(data, 0, n)
开发者ID:Alli1223,项目名称:Comp120-moodboard,代码行数:16,代码来源:Output.py

示例7: __readBytes

# 需要导入模块: from java.io import FileInputStream [as 别名]
# 或者: from java.io.FileInputStream import read [as 别名]
def __readBytes(file):
	# Returns the contents of the file in a byte array.
	inputstream = FileInputStream(file)
    
	# Get the size of the file
	length = file.length()

	# Create the byte array to hold the data
	bytes = jarray.zeros(length, "b")

	# Read in the bytes
	offset = 0
	numRead = 1
        while (offset < length) and (numRead > 0):
		numRead = inputstream.read(bytes, offset, len(bytes) - offset)
		offset += numRead

	# Ensure all the bytes have been read in
	if offset < len(bytes):
		log.warn("Could not read entire contents of '" + file.getName()) 

	# Close the input stream and return bytes
	inputstream.close()
	return bytes
开发者ID:Integral-Technology-Solutions,项目名称:ConfigNOW,代码行数:26,代码来源:common.py

示例8: FileInputStream

# 需要导入模块: from java.io import FileInputStream [as 别名]
# 或者: from java.io.FileInputStream import read [as 别名]
    try:
        Integer.byteValue()
    except:
        print 'regression:       no crash yet'
    #raise TypeError, 'test'

    print """
    ##################################################
    # array handling
    ##################################################
    """

    # just for fun
    fin = FileInputStream("configure")
    ar = jarray(20, JBYTE_ID)
    count = fin.read(ar)

    # strip any other lines, just want first
    if(10 in ar):
        count = ar.index(10)
        ar = ar[0:count]
    print 'configure starts ', String(ar, 0, count)
    fin.close()
    
    # array handling
    ar = testo.getStringArray()
    print 'string[] len:    ', len(ar)
    print '[0], [1], [2]:   ', ar[0], ar[1], ar[2]
    ar[0] = "new"
    ar[1] = None
    print '[0], [1]:        ', ar[0], ar[1]
开发者ID:Kroisse,项目名称:jep,代码行数:33,代码来源:test.py


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