2015-07-20 62 views

回答

1

我發現了另一個解決方案,用於在不詢問目錄的情況下在geb中保存zip。 我配置我GebConfig.groovy:

profile.setPreference("browser.download.folderList",2) 
    profile.setPreference("browser.download.manager.showWhenStarting",false) 
    profile.setPreference("browser.download.dir", new File("").getAbsolutePath()) 
    profile.setPreference("browser.helperApps.neverAsk.saveToDisk","application/zip") 
1

文件不過是一個字節數組。你需要實際做什麼?例如,您可以使用FileOutputStream將其保存在某處。 您可以使用ZipInputStream(使用ByteArrayInputStream)直接在Java中讀取條目...那麼,您想實際執行什麼操作?

+0

我需要保存這個拉鍊在當前目錄 –

+0

你可以寫通過FileOutputStream中的寫入方法,它是做最基本的方法的字節數組。另請參見http://stackoverflow.com/questions/4350084/byte-to-file-in-java –

+0

我試過這個: 但我無法打開zip文件 FileOutputStream fos = new FileOutputStream(filename +「。zip」 ); fos.write(byteArr); fos.close(); –