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


Python FileOutputStream.close方法代码示例

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


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

示例1: transformReport

# 需要导入模块: from java.io import FileOutputStream [as 别名]
# 或者: from java.io.FileOutputStream import close [as 别名]
class report_generation:
  'Test Report Generation'

  def transformReport(self,stylesheet,xml,output,params):
    from java.io import FileInputStream
    from java.io import FileOutputStream
    from java.io import ByteArrayOutputStream

    from javax.xml.transform import TransformerFactory
    from javax.xml.transform.stream import StreamSource
    from javax.xml.transform.stream import StreamResult

    self.xsl   = FileInputStream("%s" % stylesheet)
    self.xml   = FileInputStream("%s" % xml)
    self.html  = FileOutputStream("%s" % output)

    try:
      self.xslSource   = StreamSource(self.xsl)
      self.tfactory    = TransformerFactory.newInstance()
      self.xslTemplate = self.tfactory.newTemplates(self.xslSource)
      self.transformer = self.xslTemplate.newTransformer()

      self.source = StreamSource(self.xml)
      self.result = StreamResult(self.html)

      for self.key,self.value in params.items():
        self.transformer.setParameter(self.key, self.value)

      self.transformer.transform(self.source, self.result)

    finally:
      self.xsl.close()
      self.xml.close()
      self.html.close()
开发者ID:SmarterApp,项目名称:IM_OpenDJ,代码行数:36,代码来源:common.py

示例2: saveHM

# 需要导入模块: from java.io import FileOutputStream [as 别名]
# 或者: from java.io.FileOutputStream import close [as 别名]
def saveHM(filename):
    # Create new HTTP client
    client = HttpClient()
    client.getParams().setAuthenticationPreemptive(True)
    defaultcreds = UsernamePasswordCredentials(user, password)
    client.getState().setCredentials(AuthScope.ANY, defaultcreds)

    # Get data across HTTP
    url = (
        "http://"
        + host
        + ":"
        + str(port)
        + "/admin/savedataview.egi?type="
        + type
        + "&data_format=NEXUSHDF5_LZW_6&data_saveopen_action=OPEN_ONLY"
    )
    getMethod = GetMethod(url)
    getMethod.setDoAuthentication(True)
    client.executeMethod(getMethod)

    # Save locally
    file = File(directory + "/" + filename)
    out = FileOutputStream(file)
    out.write(getMethod.getResponseBody())
    out.close()

    # Clean up
    getMethod.releaseConnection()
开发者ID:Gumtree,项目名称:Quokka_scripts,代码行数:31,代码来源:detectorscanTOF_25aug2013_increasing_dist.py

示例3: XmlWriter

# 需要导入模块: from java.io import FileOutputStream [as 别名]
# 或者: from java.io.FileOutputStream import close [as 别名]
class XmlWriter(AbstractXmlWriter):

    def __init__(self, path):
        self.path = path
        self._output = FileOutputStream(path)
        self._writer = SAXTransformerFactory.newInstance().newTransformerHandler()
        self._writer.setResult(StreamResult(self._output))
        self._writer.startDocument()
        self.content('\n')
        self.closed = False

    def start(self, name, attributes={}, newline=True):
        attrs = AttributesImpl()
        for attrname, attrvalue in attributes.items():
            attrs.addAttribute('', '', attrname, '', attrvalue)
        self._writer.startElement('', '', name, attrs)
        if newline:
            self.content('\n')

    def content(self, content):
        if content is not None:
            content = self._encode(content)
            self._writer.characters(content, 0, len(content))

    def end(self, name, newline=True):
        self._writer.endElement('', '', name)
        if newline:
            self.content('\n')

    def close(self):
        self._writer.endDocument()
        self._output.close()
        self.closed = True
开发者ID:superbaby11,项目名称:autoOMC,代码行数:35,代码来源:jyxmlwriter.py

示例4: extractZip

# 需要导入模块: from java.io import FileOutputStream [as 别名]
# 或者: from java.io.FileOutputStream import close [as 别名]
def extractZip(zip, dest):
    "extract zip archive to dest directory"
    
    logger.info("Begin extracting:" + zip + " --> " +dest)
    mkdir_p(dest)
    zipfile = ZipFile(zip)

    entries = zipfile.entries()
    while entries.hasMoreElements():
        entry = entries.nextElement()

        if entry.isDirectory():
            mkdir_p(os.path.join(dest, entry.name))
        else:
            newFile = File(dest, entry.name)
            mkdir_p(newFile.parent)
            zis = zipfile.getInputStream(entry)
            fos = FileOutputStream(newFile)
            nread = 0
            buffer = ByteBuffer.allocate(1024)
            while True:
                nread = zis.read(buffer.array(), 0, 1024)
                if nread <= 0:
                        break
                fos.write(buffer.array(), 0, nread)

            fos.close()
            zis.close()

    logger.info("End extracting:" + str(zip) + " --> " + str(dest))
开发者ID:fabrician,项目名称:docker-swarm-enabler,代码行数:32,代码来源:DockerSwarmEnabler.py

示例5: retrieve_an_archive

# 需要导入模块: from java.io import FileOutputStream [as 别名]
# 或者: from java.io.FileOutputStream import close [as 别名]
def retrieve_an_archive(cust_id, archive_name, user_id, chunk_hint, file_name, output_ids):
    print "\nretrieve_a_chunk routine:: output file_name is :", file_name

    try:
        outfile_stream = FileOutputStream(file_name)
    except:
        print "retrieve_a_chunk routine:: Failed to open output stream on file : ", file_name, "..returning"
        return None

    # retrieve data
    mc = ManagementContainer.getInstance()
    rm = mc.getRecoveryManager()

    l_cust_id = Integer.parseInt(cust_id);
    l_user_id = Integer.parseInt(user_id);
    sosw = IRecoveryManager.SimpleOutputStreamWrapper(outfile_stream)

    try:
        rm.createPerUserActiveRecoveryArchiveFile(l_cust_id, archive_name, l_user_id, sosw, chunk_hint)
    except:
        print "retrieve_a_chunk routine:: `Exception while creating active recovery archive..returning"
        sys.exc_info()[1].printStackTrace()

        print("*** print_exc:")
        traceback.print_exc(file=sys.stdout)
        outfile_stream.close()
        raise

    outfile_stream.close()
    return get_chunk_hint(file_name, output_ids)
开发者ID:piyush76,项目名称:MyPythonModule,代码行数:32,代码来源:verify_archive_download.py

示例6: getMsgRaw

# 需要导入模块: from java.io import FileOutputStream [as 别名]
# 或者: from java.io.FileOutputStream import close [as 别名]
def getMsgRaw(fileName, rs):
    msgID = rs.getLong(1)
    size = rs.getInt(2)
    storageLocation = StoredMessage.stripOldStorageDir(rs.getString(3))
    custID = rs.getInt(4)
    ts = rs.getTimestamp(5)
    receivedDate = None
    if ts is not None:
        receivedDate = Date(ts.getTime)
    msg = StoredMessage(custID, msgID, storageLocation, None, None, receivedDate, 0, 0, 0, 0, None, amPartId, size, size, None, None)

    if msg:
        # do some validation
        if long(msgId) != msg.getMessageId():
            printQueue.append("consumer: ERROR: message ID " + str(msgId) + " not the same as " + str(msg.getMessageId()))

        #print "found message", msgId, "in DB for AM partition"
        msgStream = msg.getEncryptedCompressedContentStream()
        if msgStream:
            out = FileOutputStream(fileName)
            FileUtils.copyStream(msg.getEncryptedCompressedContentStream(), out)
            out.flush()
            out.close()
            #print "found message", msgId, "on disk in AM partition"
            return True
        else:
            printErrorToRemigrate(msgId, " not found on disk for AM partition.")
            return False
    else:
        printErrorToRemigrate(msgId, " not found in db for AM partition.")
        return False
开发者ID:piyush76,项目名称:EMS,代码行数:33,代码来源:dx_script_unsorted.py

示例7: __getFile

# 需要导入模块: from java.io import FileOutputStream [as 别名]
# 或者: from java.io.FileOutputStream import close [as 别名]
 def __getFile(self, packageDir, filename):
     file = File(packageDir, filename)
     if not file.exists():
         out = FileOutputStream(file)
         IOUtils.copy(Services.getClass().getResourceAsStream("/workflows/" + filename), out)
         out.close()
     return file
开发者ID:kiranba,项目名称:the-fascinator,代码行数:9,代码来源:packaging.py

示例8: replaceDocumentSummary

# 需要导入模块: from java.io import FileOutputStream [as 别名]
# 或者: from java.io.FileOutputStream import close [as 别名]
 def replaceDocumentSummary(self, ole2filename, blank=False):
    fin = FileInputStream(ole2filename)
    fs = NPOIFSFileSystem(fin)
    root = fs.getRoot()
    si = False
    siFound = False
    for obj in root:
       x = obj.getShortDescription()
       if x == (u"\u0005" + "DocumentSummaryInformation"):   
          siFound=True
          if blank == False:
             test = root.getEntry((u"\u0005" + "DocumentSummaryInformation")) 
             dis = DocumentInputStream(test);
             ps = PropertySet(dis);
             try:
                si = DocumentSummaryInformation(ps)
             except UnexpectedPropertySetTypeException as e:
                sys.stderr.write("Error writing old DocumentSymmaryInformation:" + str(e).replace('org.apache.poi.hpsf.UnexpectedPropertySetTypeException:',''))
                sys.exit(1)
                
    if blank == False and siFound == True:
       si.write(root, (u"\u0005" + "DocumentSummaryInformation"))
    else:
       ps = PropertySetFactory.newDocumentSummaryInformation()      
       ps.write(root, (u"\u0005" + "DocumentSummaryInformation"));
    
    out = FileOutputStream(ole2filename);
    fs.writeFilesystem(out);
    out.close();
开发者ID:exponential-decay,项目名称:ole2-re-combiner,代码行数:31,代码来源:JHandleOLE2Containers.py

示例9: replaceSummaryInfo

# 需要导入模块: from java.io import FileOutputStream [as 别名]
# 或者: from java.io.FileOutputStream import close [as 别名]
   def replaceSummaryInfo(self, ole2filename, blank=False):

      fin = FileInputStream(ole2filename)
      fs = NPOIFSFileSystem(fin)
      root = fs.getRoot()
      si = False
      siFound = False
      for obj in root:
         x = obj.getShortDescription()
         if x == (u"\u0005" + "SummaryInformation"):
            siFound = True
            if blank == False:
               test = root.getEntry((u"\u0005" + "SummaryInformation")) 
               dis = DocumentInputStream(test);
               ps = PropertySet(dis);
               #https://poi.apache.org/apidocs/org/apache/poi/hpsf/SummaryInformation.html
               si = SummaryInformation(ps);

      if blank == False and siFound == True:
         si.write(root, (u"\u0005" + "SummaryInformation"))
      else:
         ps = PropertySetFactory.newSummaryInformation()      
         ps.write(root, (u"\u0005" + "SummaryInformation"));
      
      out = FileOutputStream(ole2filename);
      fs.writeFilesystem(out);
      out.close();
开发者ID:exponential-decay,项目名称:ole2-re-combiner,代码行数:29,代码来源:JHandleOLE2Containers.py

示例10: exportAll

# 需要导入模块: from java.io import FileOutputStream [as 别名]
# 或者: from java.io.FileOutputStream import close [as 别名]
def exportAll(exportConfigFile, generalConfigFile):
    try:
        print "Loading export config from :", exportConfigFile
        exportConfigProp = loadProps(exportConfigFile,generalConfigFile)
        adminUrl = exportConfigProp.get("adminUrl")
        user = exportConfigProp.get("user")
        passwd = exportConfigProp.get("password")

        jarFileName = exportConfigProp.get("jarFileName")
        customFile = exportConfigProp.get("customizationFile")

        passphrase = exportConfigProp.get("passphrase")
        project = exportConfigProp.get("project")

        connectToServer(user, passwd, adminUrl)
        print 'connected'

        ALSBConfigurationMBean = findService("ALSBConfiguration", "com.bea.wli.sb.management.configuration.ALSBConfigurationMBean")
        print "ALSBConfiguration MBean found"

        print project
        if project == None :
            ref = Ref.DOMAIN
            collection = Collections.singleton(ref)
            if passphrase == None :
                print "Export the config"
                theBytes = ALSBConfigurationMBean.export(collection, true, None)
            else :
                print "Export and encrypt the config"
                theBytes = ALSBConfigurationMBean.export(collection, true, passphrase)
        else :
            ref = Ref.makeProjectRef(project);
            print "Export the project", project
            collection = Collections.singleton(ref)
            theBytes = ALSBConfigurationMBean.exportProjects(collection, passphrase)
        print 'fileName',jarFileName
        aFile = File(jarFileName)
        print 'file',aFile
        out = FileOutputStream(aFile)
        out.write(theBytes)
        out.close()
        print "ALSB Configuration file: "+ jarFileName + " has been exported"

        if customFile != None:
            print collection
            query = EnvValueQuery(None, Collections.singleton(EnvValueTypes.WORK_MANAGER), collection, false, None, false)
            customEnv = FindAndReplaceCustomization('Set the right Work Manager', query, 'Production System Work Manager')
            print 'EnvValueCustomization created'
            customList = ArrayList()
            customList.add(customEnv)
            print customList
            aFile = File(customFile)
            out = FileOutputStream(aFile)
            Customization.toXML(customList, out)
            out.close()

#        print "ALSB Dummy Customization file: "+ customFile + " has been created"
    except:
        raise
开发者ID:robertoporfiro,项目名称:guavatools,代码行数:61,代码来源:export.py

示例11: save_versions

# 需要导入模块: from java.io import FileOutputStream [as 别名]
# 或者: from java.io.FileOutputStream import close [as 别名]
 def save_versions(self):
     print "save versions"
     versionsProperties = Properties()
     outFile = FileOutputStream(self.versionsFileName)
     versionsProperties.setProperty("script", self.app.SCRIPTVERSION)
     versionsProperties.setProperty("tools", self.app.TOOLSVERSION)
     versionsProperties.store(outFile, None)
     outFile.close()
开发者ID:alex85k,项目名称:qat_script,代码行数:10,代码来源:config_reader.py

示例12: save_example

# 需要导入模块: from java.io import FileOutputStream [as 别名]
# 或者: from java.io.FileOutputStream import close [as 别名]
 def save_example(self, label, image_byte_array):
     output_file_name = label + "_" + str(java.lang.System.currentTimeMillis()) + ".png"
     save_path = File(self.dir_path, output_file_name).getCanonicalPath()
     fileos = FileOutputStream(save_path)
     for byte in image_byte_array:
         fileos.write(byte)
     fileos.flush()
     fileos.close()
开发者ID:Jonny-James,项目名称:HandReco,代码行数:10,代码来源:image_example_dir.py

示例13: save_config

# 需要导入模块: from java.io import FileOutputStream [as 别名]
# 或者: from java.io.FileOutputStream import close [as 别名]
 def save_config(self):
     """Save preferences to config file
     """
     out = FileOutputStream(app.configFileName)
     app.properties.store(out, None)
     out.close()
     #load new preferences
     self.config = ConfigLoader(self)
开发者ID:alex85k,项目名称:qat_script,代码行数:10,代码来源:qat_script.py

示例14: run

# 需要导入模块: from java.io import FileOutputStream [as 别名]
# 或者: from java.io.FileOutputStream import close [as 别名]
 def run(self):
     while 1:
         print "Writing out channels", Date()
         ostream = FileOutputStream(self.filename)
         p = ObjectOutputStream(ostream)
         p.writeObject(self.registry.getChannelGroup("Default"))
         p.flush()
         ostream.close()
         self.sleep(self.delay)
开发者ID:optivo-org,项目名称:informa-0.7.0-optivo,代码行数:11,代码来源:minigui.py

示例15: writeToFile

# 需要导入模块: from java.io import FileOutputStream [as 别名]
# 或者: from java.io.FileOutputStream import close [as 别名]
def writeToFile(text, testId):
    filename = "log/%s-%s-page-%d.html" % (grinder.processName,
                                       testId,
                                       grinder.runNumber)

    # Use Java FileOutputStream since it has better Unicode handling
    os = FileOutputStream(filename)
    os.write(text)
    os.close()
开发者ID:PowerToChange,项目名称:com.powertochange.powertochangesurvey,代码行数:11,代码来源:mycravings_survey_1.py


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