List of usage examples for java.util.zip ZipOutputStream flush
public void flush() throws IOException
From source file:net.sf.smbt.touchosc.utils.TouchOSCUtils.java
public void dumpTouchOsc(TOP top, String destDirname, String destFilename) { reverseZOrders(top);//from w ww.j av a2s . c o m // // Get tests for TouchOSC legacy compliances : need precise version info // //applyBase64Transformation(top); // Create a resource set. // ResourceSet resourceSet = new ResourceSetImpl(); // // Register the default resource factory -- only needed for stand-alone! // resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(TouchoscPackage.eNS_PREFIX, new TouchoscResourceFactoryImpl()); resourceSet.getPackageRegistry().put(TouchoscPackage.eNS_URI, TouchoscPackage.eINSTANCE); resourceSet.getPackageRegistry().put(TouchoscappPackage.eNS_URI, TouchoscappPackage.eINSTANCE); String dirname; if (destDirname == null) { dirname = Platform.getInstanceLocation().getURL().getPath() + "/" + UUID.randomUUID().toString(); if (Platform.inDebugMode()) { System.out.println("creating " + dirname + " directory"); } new File(dirname).mkdir(); } else { dirname = destDirname; } // // Get the URI of the model file. // URI touchoscURI = URI.createFileURI(dirname + "/" + "index.xml"); // // Demand load the resource for this file. // Resource resource = resourceSet.createResource(touchoscURI); resource.getContents().add(top); try { Map<Object, Object> options = new HashMap<Object, Object>(); options.put(XMLResource.OPTION_ENCODING, "UTF-8"); resource.save(options); } catch (IOException e) { e.printStackTrace(); } String TOUCHOSC_HEADER = "<touchosc:TOP xmi:version=\"2.0\" xmlns:xmi=\"http://www.omg.org/XMI\" xmlns:touchosc=\"http:///net.sf.smbt.touchosc/src/net/sf/smbt/touchosc/model/touchosc.xsd\">"; String TOUCHOSC_FOOTER = "</touchosc:TOP>"; String path = touchoscURI.path().toString(); String outputZipFile = dirname + "/" + destFilename + ".touchosc"; try { FileInputStream touchoscFile = new FileInputStream(path); BufferedReader reader = new BufferedReader( new InputStreamReader(touchoscFile, Charset.forName("ASCII"))); CharBuffer charBuffer = CharBuffer.allocate(65535); while (reader.read(charBuffer) != -1) charBuffer.flip(); String content = charBuffer.toString(); content = content.replace(TOUCHOSC_HEADER, "<touchosc>"); content = content.replace(TOUCHOSC_FOOTER, "</touchosc>"); content = content.replace("<layout>", "<layout version=\"10\" mode=\"" + top.getLayout().getMode() + "\" orientation=\"" + top.getLayout().getOrientation() + "\">"); content = content.replace("numberX=", "number_x="); content = content.replace("numberY=", "number_y="); content = content.replace("invertedX=", "inverted_x="); content = content.replace("invertedY=", "inverted_y="); content = content.replace("localOff=", "local_off="); content = content.replace("oscCs=", "osc_cs="); content = content.replace("xypad", "xy"); touchoscFile.close(); FileOutputStream os = new FileOutputStream(path); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os, Charset.forName("UTF-8"))); writer.write(content); writer.flush(); os.flush(); os.close(); FileOutputStream fos = new FileOutputStream(outputZipFile); ZipOutputStream fileOS = new ZipOutputStream(fos); ZipEntry ze = new ZipEntry("index.xml"); fileOS.putNextEntry(ze); fileOS.write(content.getBytes(Charset.forName("UTF-8"))); fileOS.flush(); fileOS.close(); fos.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException ioe) { ioe.printStackTrace(); } finally { File f = new File(path); if (f.exists() && f.canWrite()) { if (!f.delete()) { throw new IllegalArgumentException(path + " deletion failed"); } } } }
From source file:com.founder.fix.fixflow.FlowManager.java
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { CurrentThread.init();/*w ww . java2 s .c o m*/ String userId = StringUtil.getString(request.getSession().getAttribute(FlowCenterService.LOGIN_USER_ID)); if (StringUtil.isEmpty(userId)) { String context = request.getContextPath(); response.sendRedirect(context + "/"); return; } ServletOutputStream out = null; String action = StringUtil.getString(request.getParameter("action")); if (StringUtil.isEmpty(action)) { action = StringUtil.getString(request.getAttribute("action")); } RequestDispatcher rd = null; try { Map<String, Object> filter = new HashMap<String, Object>(); if (ServletFileUpload.isMultipartContent(request)) { ServletFileUpload Uploader = new ServletFileUpload(new DiskFileItemFactory()); // Uploader.setSizeMax("); // Uploader.setHeaderEncoding("utf-8"); List<FileItem> fileItems = Uploader.parseRequest(request); for (FileItem item : fileItems) { filter.put(item.getFieldName(), item); if (item.getFieldName().equals("action")) action = item.getString(); if (item.getFieldName().equals("deploymentId")) { filter.put("deploymentId", item.getString()); } } } else { Enumeration enu = request.getParameterNames(); while (enu.hasMoreElements()) { Object tmp = enu.nextElement(); Object obj = request.getParameter(StringUtil.getString(tmp)); // if (request.getAttribute("ISGET") != null) obj = new String(obj.toString().getBytes("ISO8859-1"), "utf-8"); filter.put(StringUtil.getString(tmp), obj); } } Enumeration attenums = request.getAttributeNames(); while (attenums.hasMoreElements()) { String paramName = (String) attenums.nextElement(); Object paramValue = request.getAttribute(paramName); // ?map filter.put(paramName, paramValue); } filter.put("userId", userId); request.setAttribute("nowAction", action); if ("processDefinitionList".equals(action)) { rd = request.getRequestDispatcher("/fixflow/manager/processDefinitionList.jsp"); Map<String, Object> result = getProcessDefinitionService().getProcessDefitionList(filter); filter.putAll(result); request.setAttribute("result", filter); request.setAttribute("pageInfo", filter.get("pageInfo")); } else if (action.equals("processManageList")) { rd = request.getRequestDispatcher("/fixflow/manager/processInstanceList.jsp"); Map<String, Object> result = getFlowManager().getProcessInstances(filter); filter.putAll(result); request.setAttribute("result", filter); request.setAttribute("pageInfo", filter.get("pageInfo")); } else if (action.equals("suspendProcessInstance")) { rd = request.getRequestDispatcher("/FlowManager?action=processManageList"); getFlowManager().suspendProcessInstance(filter); } else if (action.equals("continueProcessInstance")) { rd = request.getRequestDispatcher("/FlowManager?action=processManageList"); getFlowManager().continueProcessInstance(filter); } else if (action.equals("terminatProcessInstance")) { rd = request.getRequestDispatcher("/FlowManager?action=processManageList"); getFlowManager().terminatProcessInstance(filter); } else if (action.equals("deleteProcessInstance")) { rd = request.getRequestDispatcher("/FlowManager?action=processManageList"); getFlowManager().deleteProcessInstance(filter); } else if (action.equals("toProcessVariable")) { rd = request.getRequestDispatcher("/fixflow/manager/processVariableList.jsp"); Map<String, Object> result = getFlowManager().getProcessVariables(filter); filter.putAll(result); request.setAttribute("result", filter); } else if (action.equals("saveProcessVariables")) { String tmp = (String) filter.get("insertAndUpdate"); if (StringUtil.isNotEmpty(tmp)) { Map<String, Object> tMap = JSONUtil.parseJSON2Map(tmp); filter.put("insertAndUpdate", tMap); } getFlowManager().saveProcessVariables(filter); rd = request.getRequestDispatcher("/FlowManager?action=toProcessVariable"); } else if (action.equals("processTokenList")) { Map<String, Object> result = getFlowManager().getProcessTokens(filter); filter.putAll(result); request.setAttribute("result", filter); rd = request.getRequestDispatcher("/fixflow/manager/processTokenList.jsp"); } else if (action.equals("taskInstanceList")) { rd = request.getRequestDispatcher("/fixflow/manager/taskInstanceList.jsp"); filter.put("path", request.getSession().getServletContext().getRealPath("/")); Map<String, Object> pageResult = getTaskManager().getTaskList(filter); filter.putAll(pageResult); request.setAttribute("result", filter); request.setAttribute("pageInfo", filter.get("pageInfo")); } else if (action.equals("doTaskSuspend")) { rd = request.getRequestDispatcher("/FlowManager?action=taskInstanceList"); getTaskManager().suspendTask(filter); } else if (action.equals("doTaskResume")) { rd = request.getRequestDispatcher("/FlowManager?action=taskInstanceList"); getTaskManager().resumeTask(filter); } else if (action.equals("doTaskTransfer")) { rd = request.getRequestDispatcher("/FlowManager?action=taskInstanceList"); getTaskManager().transferTask(filter); } else if (action.equals("doTaskRollBackNode")) { rd = request.getRequestDispatcher("/FlowManager?action=taskInstanceList"); getTaskManager().rollBackNode(filter); } else if (action.equals("doTaskRollBackTask")) { rd = request.getRequestDispatcher("/FlowManager?action=taskInstanceList"); getTaskManager().rollBackStep(filter); } else if (action.equals("flowLibrary")) { rd = request.getRequestDispatcher("/fixflow-explorer/flowLibrary.jsp"); } //???deploymentId if ("deploy".equals(action)) { rd = request.getRequestDispatcher("/FlowManager?action=processDefinitionList"); response.setContentType("text/html;charset=utf-8"); getProcessDefinitionService().deployByZip(filter); } else if ("deleteDeploy".equals(action)) { rd = request.getRequestDispatcher("/FlowManager?action=processDefinitionList"); getProcessDefinitionService().deleteDeploy(filter); } else if ("download".equals(action)) { String processDefinitionId = StringUtil.getString(filter.get("processDefinitionId")); response.reset(); request.setCharacterEncoding("gbk"); response.setContentType("applcation/octet-stream"); response.setHeader("Content-disposition", "attachment; filename=" + processDefinitionId + ".zip"); response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0,private, max-age=0"); response.setHeader("Content-Type", "application/octet-stream"); response.setHeader("Content-Type", "application/force-download"); response.setHeader("Pragma", "public"); response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0"); ZipOutputStream outZip = new ZipOutputStream(response.getOutputStream()); List<Map<String, Object>> fileList = getProcessDefinitionService().getResources(filter); for (Map<String, Object> file : fileList) { ZipEntry entry = new ZipEntry(file.get("FILENAME").toString()); entry.setSize(((byte[]) file.get("BYTES")).length); outZip.putNextEntry(entry); outZip.write((byte[]) file.get("BYTES")); outZip.closeEntry(); } outZip.close(); outZip.flush(); outZip.close(); } else if ("getUserList".equals(action)) { rd = request.getRequestDispatcher("/fixflow/manager/userList.jsp"); request.setAttribute("nowAction", "UserGroup"); Map<String, Object> result = getUserGroupService().getAllUsers(filter); filter.putAll(result); request.setAttribute("result", filter); List<Map<String, Object>> groupList = getUserGroupService().getAllGroupDefinition(filter); request.setAttribute("groupList", groupList); request.setAttribute("pageInfo", filter.get("pageInfo")); } else if ("getGroupList".equals(action)) { rd = request.getRequestDispatcher("/fixflow/manager/groupList.jsp"); request.setAttribute("nowAction", "UserGroup"); Map<String, Object> result = getUserGroupService().getAllGroup(filter); filter.putAll(result); request.setAttribute("result", filter); List<Map<String, Object>> groupList = getUserGroupService().getAllGroupDefinition(filter); request.setAttribute("groupList", groupList); request.setAttribute("pageInfo", filter.get("pageInfo")); } else if ("getUserInfo".equals(action)) { rd = request.getRequestDispatcher("/fixflow/manager/userInfo.jsp"); Map<String, Object> pageResult = getUserGroupService().getUserInfo(filter); filter.putAll(pageResult); request.setAttribute("result", filter); } else if ("getGroupInfo".equals(action)) { rd = request.getRequestDispatcher("/fixflow/manager/groupInfo.jsp"); Map<String, Object> pageResult = getUserGroupService().getGroupInfo(filter); filter.putAll(pageResult); request.setAttribute("result", filter); } else if ("getJobList".equals(action)) { rd = request.getRequestDispatcher("/fixflow/manager/jobList.jsp"); request.setAttribute("nowAction", "jobManager"); Map<String, Object> result = getJobService().getJobList(filter); filter.putAll(result); request.setAttribute("result", filter); } else if ("viewJobInfo".equals(action)) { rd = request.getRequestDispatcher("/fixflow/manager/jobInfo.jsp"); request.setAttribute("nowAction", "jobManager"); Map<String, Object> result = getJobService().getJobTrigger(filter); filter.putAll(result); request.setAttribute("result", filter); } else if ("suspendJob".equals(action)) { rd = request.getRequestDispatcher("/fixflow/manager/jobList.jsp"); request.setAttribute("nowAction", "jobManager"); getJobService().suspendJob(filter); Map<String, Object> result = getJobService().getJobList(filter); filter.putAll(result); request.setAttribute("result", filter); } else if ("continueJob".equals(action)) { rd = request.getRequestDispatcher("/fixflow/manager/jobList.jsp"); getJobService().continueJob(filter); request.setAttribute("nowAction", "jobManager"); Map<String, Object> result = getJobService().getJobList(filter); filter.putAll(result); request.setAttribute("result", filter); } else if ("suspendTrigger".equals(action)) { rd = request.getRequestDispatcher("/fixflow/manager/jobInfo.jsp"); getJobService().suspendTrigger(filter); request.setAttribute("nowAction", "jobManager"); Map<String, Object> result = getJobService().getJobTrigger(filter); filter.putAll(result); request.setAttribute("result", filter); } else if ("continueTrigger".equals(action)) { rd = request.getRequestDispatcher("/fixflow/manager/jobInfo.jsp"); getJobService().continueTrigger(filter); request.setAttribute("nowAction", "jobManager"); Map<String, Object> result = getJobService().getJobTrigger(filter); filter.putAll(result); request.setAttribute("result", filter); } else if ("setHis".equals(action)) { rd = request.getRequestDispatcher("/FlowManager?action=processManageList"); getFlowManager().setHistory(filter); } else if ("updateCache".equals(action)) { ProcessEngineManagement.getDefaultProcessEngine().cleanCache(true, true); response.getWriter().write("update success!"); } } catch (Exception e) { e.printStackTrace(); request.setAttribute("errorMsg", e.getMessage()); try { CurrentThread.rollBack(); } catch (SQLException e1) { e1.printStackTrace(); request.setAttribute("errorMsg", e.getMessage()); } } finally { if (out != null) { out.flush(); out.close(); } try { CurrentThread.clear(); } catch (SQLException e) { e.printStackTrace(); request.setAttribute("errorMsg", e.getMessage()); } } if (rd != null) rd.forward(request, response); }
From source file:net.solarnetwork.node.backup.FileSystemBackupService.java
@Override public Backup performBackup(final Iterable<BackupResource> resources) { if (resources == null) { return null; }// ww w . j av a 2s. com final Iterator<BackupResource> itr = resources.iterator(); if (!itr.hasNext()) { log.debug("No resources provided, nothing to backup"); return null; } BackupStatus status = setStatusIf(RunningBackup, Configured); if (status != RunningBackup) { return null; } final Calendar now = new GregorianCalendar(); now.set(Calendar.MILLISECOND, 0); final String archiveName = String.format(ARCHIVE_NAME_FORMAT, now); final File archiveFile = new File(backupDir, archiveName); final String archiveKey = getArchiveKey(archiveName); log.info("Starting backup to archive {}", archiveName); log.trace("Backup archive: {}", archiveFile.getAbsolutePath()); Backup backup = null; ZipOutputStream zos = null; try { zos = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(archiveFile))); while (itr.hasNext()) { BackupResource r = itr.next(); log.debug("Backup up resource {} to archive {}", r.getBackupPath(), archiveName); zos.putNextEntry(new ZipEntry(r.getBackupPath())); FileCopyUtils.copy(r.getInputStream(), new FilterOutputStream(zos) { @Override public void close() throws IOException { // FileCopyUtils closes the stream, which we don't want } }); } zos.flush(); zos.finish(); log.info("Backup complete to archive {}", archiveName); backup = new SimpleBackup(now.getTime(), archiveKey, archiveFile.length(), true); // clean out older backups File[] backupFiles = getAvailableBackupFiles(); if (backupFiles != null && backupFiles.length > additionalBackupCount + 1) { // delete older files for (int i = additionalBackupCount + 1; i < backupFiles.length; i++) { log.info("Deleting old backup archive {}", backupFiles[i].getName()); if (!backupFiles[i].delete()) { log.warn("Unable to delete backup archive {}", backupFiles[i].getAbsolutePath()); } } } } catch (IOException e) { log.error("IO error creating backup: {}", e.getMessage()); setStatus(Error); } catch (RuntimeException e) { log.error("Error creating backup: {}", e.getMessage()); setStatus(Error); } finally { if (zos != null) { try { zos.close(); } catch (IOException e) { // ignore this } } status = setStatusIf(Configured, RunningBackup); if (status != Configured) { // clean up if we encountered an error if (archiveFile.exists()) { archiveFile.delete(); } } } return backup; }
From source file:util.CreationZipTool.java
public void createZip(List zipfiles, HttpServletResponse response, String filename) throws Exception { try {// w ww.j av a 2 s . c om if ((zipfiles == null) || (response == null) || (filename == null)) { return; } ZipOutputStream zos = new ZipOutputStream(response.getOutputStream()); String header = "attachment; filename=" + filename; response.setHeader("Content-Disposition", header); response.setContentType("application/octet-stream"); //response.setHeader("Content-Disposition", "attachment; filename=photos.zip"); /** * Get the list of files from an array */ for (int i = 0; i < zipfiles.size(); i++) { // logger.info("filename " + ((Photo)zipfiles.get(i)).getValue(DbConstants.BTITLE)); /** * Add a file name & file content to the entry */ ZipEntry entry = new ZipEntry(((Photo) zipfiles.get(i)).getValue(DbConstants.BTITLE)); zos.putNextEntry(entry); byte[] b = ((Photo) zipfiles.get(i)).getBlob(); zos.write(b, 0, b.length); zos.closeEntry(); } zos.flush(); zos.close(); } catch (Exception e) { throw new Exception("Could not create zip file: ", e); } }
From source file:org.geoserver.catalog.rest.DataStoreFileResource.java
@Override public void handleGet() { String workspace = getAttribute("workspace"); String datastore = getAttribute("datastore"); String format = getAttribute("format"); //find the directory from teh datastore connection parameters DataStoreInfo info = catalog.getDataStoreByName(workspace, datastore); if (info == null) { throw new RestletException("No such datastore " + datastore, Status.CLIENT_ERROR_NOT_FOUND); }//from w ww . jav a 2 s .c o m Map<String, Serializable> params = info.getConnectionParameters(); File directory = null; for (Map.Entry<String, Serializable> e : params.entrySet()) { if (e.getValue() instanceof File) { directory = (File) e.getValue(); } else if (e.getValue() instanceof URL) { directory = new File(((URL) e.getValue()).getFile()); } if (directory != null && !"directory".equals(e.getKey())) { directory = directory.getParentFile(); } if (directory != null) { break; } } if (directory == null || !directory.exists() || !directory.isDirectory()) { throw new RestletException("No files for datastore " + datastore, Status.CLIENT_ERROR_NOT_FOUND); } //zip up all the files in the directory StreamDataFormat fmt = new StreamDataFormat(MediaType.APPLICATION_ZIP) { @Override protected Object read(InputStream in) throws IOException { return null; } @Override protected void write(Object object, OutputStream out) throws IOException { ZipOutputStream zout = new ZipOutputStream(out); File directory = (File) object; for (File f : directory.listFiles()) { ZipEntry entry = new ZipEntry(f.getName()); zout.putNextEntry(entry); FileInputStream fis = null; try { fis = new FileInputStream(f); IOUtils.copy(fis, zout); } finally { IOUtils.closeQuietly(fis); } zout.closeEntry(); } zout.flush(); zout.close(); } }; getResponse().setEntity(fmt.toRepresentation(directory)); }
From source file:org.exoplatform.services.jcr.ext.artifact.ArtifactManagingServiceImpl.java
public void exportArtifacts(SessionProvider sp, FolderDescriptor parentFolder, OutputStream out) throws RepositoryException, FileNotFoundException { Session session = currentSession(sp); Node parentNode;/*from ww w . j a v a 2 s. co m*/ if (rootNodePath.length() > 1) { parentNode = (Node) session.getItem(rootNodePath + "/" + parentFolder.getAsPath()); } else { parentNode = (Node) session.getItem("/" + parentFolder.getAsPath()); } LOG.info("Write repository to zipped stream"); ZipOutputStream zout = new ZipOutputStream(new BufferedOutputStream(out, BUFFER)); try { mapRepositoryToZipStream(parentNode, zout); zout.flush(); zout.close(); } catch (IOException e) { LOG.error("Cannot write to zip stream", e); } }
From source file:com.funambol.framework.tools.FileArchiver.java
private void internalCompress(FileOutputStream outputStream) throws FileArchiverException { ZipOutputStream zipOutputStream = new ZipOutputStream(outputStream); if (sourceFile.exists()) { if (sourceFile.isFile()) { addFile(zipOutputStream, EMPTY_PATH, sourceFile); } else if (sourceFile.isDirectory()) { if (includeRoot) { addDirectory(zipOutputStream, EMPTY_PATH, sourceFile); } else { addDirectoryContent(zipOutputStream, EMPTY_PATH, sourceFile); }//from w w w.jav a 2s. com } else { throw new FileArchiverException("Unable to handle input file type."); } } else { throw new FileArchiverException("Unable to zip a not existing file"); } try { zipOutputStream.flush(); zipOutputStream.close(); } catch (IOException e) { throw new FileArchiverException( "Unable to close the zip destination file '" + destinationFilename + "'", e); } }
From source file:org.opencms.workplace.tools.git.CmsGitCheckin.java
/** * Creates ZIP file data from the files / subfolders of the given root folder, and sends it to the given stream.<p> * * The stream passed as an argument is closed after the data is written. * * @param root the folder to zip/*from w w w .j a va2s . co m*/ * @param zipOutput the output stream which the zip file data should be written to * * @throws Exception if something goes wrong */ public static void zipRfsFolder(final File root, final OutputStream zipOutput) throws Exception { final ZipOutputStream zip = new ZipOutputStream(zipOutput); try { CmsFileUtil.walkFileSystem(root, new Closure() { @SuppressWarnings("resource") public void execute(Object stateObj) { try { FileWalkState state = (FileWalkState) stateObj; for (File file : state.getFiles()) { String relativePath = Paths.get(root.getAbsolutePath()) .relativize(Paths.get(file.getAbsolutePath())).toString(); ZipEntry entry = new ZipEntry(relativePath); entry.setTime(file.lastModified()); zip.putNextEntry(entry); zip.write(CmsFileUtil.readFully(new FileInputStream(file))); zip.closeEntry(); } } catch (Exception e) { throw new RuntimeException(e); } } }); } catch (RuntimeException e) { if (e.getCause() instanceof Exception) { throw (Exception) (e.getCause()); } else { throw e; } } zip.flush(); zip.close(); }
From source file:com.pari.nm.utils.backup.BackupRestore.java
public boolean zipFolder(File backupDir, File backupZipFile) { FileOutputStream fileWriter = null; ZipOutputStream zip = null; try {//from www.j a va 2 s .c o m fileWriter = new FileOutputStream(backupZipFile); zip = new ZipOutputStream(fileWriter); addFolderToZip("", backupDir, zip); zip.flush(); } catch (Exception e) { e.printStackTrace(); return false; } finally { try { if (zip != null) { zip.close(); } } catch (IOException ignore) { } try { if (fileWriter != null) { fileWriter.close(); } } catch (IOException ignore) { } } return true; }
From source file:com.joliciel.csvLearner.CSVLearner.java
private void doCommandTrain() throws IOException { if (resultFilePath == null) throw new RuntimeException("Missing argument: resultFile"); if (featureDir == null) throw new RuntimeException("Missing argument: featureDir"); if (maxentModelFilePath == null) throw new RuntimeException("Missing argument: maxentModel"); CSVEventListReader reader = this.getReader(TrainingSetType.ALL_TRAINING, false); GenericEvents events = reader.getEvents(); if (generateEventFile) { File eventFile = new File(maxentModelFilePath + ".events.txt"); this.generateEventFile(eventFile, events); }// www. j a v a2 s.com File modelFile = new File(maxentModelFilePath); ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(modelFile, false)); zos.putNextEntry(new ZipEntry(maxentModelBaseName + ".bin")); this.train(events, zos); zos.flush(); Writer writer = new BufferedWriter(new OutputStreamWriter(zos)); zos.putNextEntry(new ZipEntry(maxentModelBaseName + ".nrm_limits.csv")); this.writeNormalisationLimits(writer); zos.flush(); zos.close(); LOG.info("#### Complete ####"); }