@Test public void testMDMoleculeCustomization() { StringWriter writer = new StringWriter(); CMLWriter cmlWriter = new CMLWriter(writer); cmlWriter.registerCustomizer(new MDMoleculeCustomizer()); try { IAtomContainer molecule = makeMDBenzene(); cmlWriter.write(molecule); } catch (Exception exception) { logger.error("Error while creating an CML2 file: ", exception.getMessage()); logger.debug(exception); Assert.fail(exception.getMessage()); } String cmlContent = writer.toString(); logger.debug("****************************** testMDMoleculeCustomization()"); logger.debug(cmlContent); logger.debug("******************************"); // System.out.println("****************************** testMDMoleculeCustomization()"); // System.out.println(cmlContent); // System.out.println("******************************"); Assert.assertTrue(cmlContent.indexOf("xmlns:md") != -1); Assert.assertTrue(cmlContent.indexOf("md:residue\"") != -1); Assert.assertTrue(cmlContent.indexOf("md:resNumber\"") != -1); Assert.assertTrue(cmlContent.indexOf("md:chargeGroup\"") != -1); Assert.assertTrue(cmlContent.indexOf("md:cgNumber\"") != -1); Assert.assertTrue(cmlContent.indexOf("md:switchingAtom\"") != -1); }
private void performHttpCall(String host, int port, String path, String expected) throws IOException { URLConnection conn = null; InputStream in = null; StringWriter writer = new StringWriter(); try { URL url = new URL( "http://" + TestSuiteEnvironment.formatPossibleIpv6Address(host) + ":" + port + "/" + path); // System.out.println("Reading response from " + url + ":"); conn = url.openConnection(); conn.setDoInput(true); in = new BufferedInputStream(conn.getInputStream()); int i = in.read(); while (i != -1) { writer.write((char) i); i = in.read(); } assertTrue((writer.toString().indexOf(expected) > -1)); // System.out.println("OK"); } finally { safeClose(in); safeClose(writer); } }
@Test public void testCloseSessionByNormalUser() throws Exception { String sessionIdString = "555"; String actionString = Action.CloseSession.toString(); long sessionIdLong = Long.parseLong(sessionIdString); when(mockHttpServletRequest.getParameter(ServletUtil.ACTION)).thenReturn(actionString); when(mockHttpServletRequest.getParameter(ServletUtil.SESSION_ID)).thenReturn(sessionIdString); // set AuthenticateOneTimeUser false prepareEnterAuthenticateOneTimeUser(false); User user = stubbingCheckUser(); UsersCache userCacheHelper = mock(UsersCache.class); mockStatic(UsersCacheFactory.class); when(UsersCacheFactory.getInstance()).thenReturn(userCacheHelper); doNothing().when(userCacheHelper); userCacheHelper.remove(sessionIdLong); // RUN... defaultConnectionStrategy.execute(mockHttpServletRequest, mockHttpServletResponse); verifyNecessaryChecks(actionString); verifyStatic(org.mockito.Mockito.times(1)); ConnectionUtil.checkUser(loginString, password, false); PrintWriter writer = mockHttpServletResponse.getWriter(); writer.flush(); System.out.println(outStringWriter.toString()); // ASSERT... assertThat(outStringWriter.toString(), is("RESPONSE:" + String.valueOf(sessionIdLong))); }
@Override protected MailContext doRender(MailContext mail) { if (isStrict()) { if (mail.getId() == null) { throw new MailRenderException("mail context id can't be null"); } if (!mailContextHolder.containsKey(mail.getId())) { throw new MailRenderException("can't find the mail context bean, bean id: " + mail.getId()); } mail = mailContextHolder.get(mail.getId()); } if (StringUtils.isNotBlank(mail.getTemplate())) { if (getTemplateResolver() == null) { throw new MailRenderException("mail template resolver can't be null"); } StringWriter sw = new StringWriter(); try { MailTemplate template = getTemplateResolver().resolveTemplateName(mail.getTemplate(), null); template.render(mail.getModel(), sw); } catch (Exception e) { logger.error("", e); } mail.setText(sw.toString()); } return mail; }
@Test public void testOpenSessionByNormalUser() throws Exception { long sessionLong = 555; String actionString = Action.OpenSession.toString(); when(mockHttpServletRequest.getParameter(ServletUtil.ACTION)).thenReturn(actionString); when(mockHttpServletRequest.getParameter(ServletUtil.PROJECT)).thenReturn(projectString); // set AuthenticateOneTimeUser false prepareEnterAuthenticateOneTimeUser(false); User user = stubbingCheckUser(); UsersCache userCacheHelper = mock(UsersCache.class); mockStatic(UsersCacheFactory.class); when(UsersCacheFactory.getInstance()).thenReturn(userCacheHelper); when(userCacheHelper.logWithProjectLabel(loginString, CLIENT_TYPE, projectString)) .thenReturn(sessionLong); // RUN... defaultConnectionStrategy.execute(mockHttpServletRequest, mockHttpServletResponse); verifyNecessaryChecks(actionString); verifyStatic(org.mockito.Mockito.times(1)); ConnectionUtil.checkUser(loginString, password, false); PrintWriter writer = mockHttpServletResponse.getWriter(); writer.flush(); System.out.println(outStringWriter.toString()); // ASSERT... assertThat(outStringWriter.toString(), is("RESPONSE:" + String.valueOf(sessionLong))); }
public synchronized String format(LogRecord record) { StringBuffer sb = new StringBuffer(); date.setTime(record.getMillis() + timeDiff); sb.append(dFormat.format(date)); if (isShowingThreads) { Thread currentThread = Thread.currentThread(); if (currentThread != lastThread) { lastThread = currentThread; lastThreadName = currentThread.getName(); } sb.append(" [").append(lastThreadName).append(']'); } sb.append(' ') .append(record.getLevel()) .append(' ') .append(getAliasFor(record.getLoggerName())) .append('|') .append(record.getMessage()) .append(EOL); if (record.getThrown() != null) { try { StringWriter out = new StringWriter(); PrintWriter pout = new PrintWriter(out); record.getThrown().printStackTrace(pout); pout.close(); sb.append(out.toString()); } catch (Exception e) { // Ignore any errors while extracting stack trace } } return sb.toString(); }
/** * 以String类型返回错误抛出的堆栈信息 * * @param t Throwable * @return String */ public static String getStackTrace(Throwable t) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); t.printStackTrace(pw); return sw.toString(); }
public static String getDebugMsg(Throwable e) { if (e == null) return null; StringWriter write = new StringWriter(); PrintWriter out = new PrintWriter(write); e.printStackTrace(out); return write.toString(); }
public SolrUpdateException(Exception ex) { initCause(ex); shortMessage = ex.getMessage(); StringWriter sw = new StringWriter(); ex.printStackTrace(new PrintWriter(sw)); messageDetail = sw.toString(); }
public static void showFatalMsg( Throwable t, String msg, final Activity activity, boolean copyTrace) { if (copyTrace && (t != null)) { StringWriter writer = new StringWriter(); t.printStackTrace(new PrintWriter(writer)); String trace = writer.toString(); Log.e(TAG, trace); copyToClipboard(trace, activity); } AbstractDialogClickListener dlgClick = new AbstractDialogClickListener() { @Override public final void onOkClicked(DialogInterface dialog) { activity.finish(); } @Override public final void onCancelClicked() { activity.finish(); } }; AlertDialog.Builder dlg = new AlertDialog.Builder(activity) .setTitle(getAppTitle(activity) + " - " + activity.getString(R.string.error)) .setMessage(msg) .setCancelable(false) .setPositiveButton(copyTrace ? R.string.copy_trace_and_close : R.string.close, dlgClick) .setOnCancelListener(dlgClick); dlg.show(); }
/** * caution: no authentication so far * * @return * @throws Exception */ public String export() throws Exception { project = projectMgr.getProject(projectId); velocityEngine.init(); VelocityContext context = new VelocityContext(); context.put("project", project); Template template = null; try { template = velocityEngine.getTemplate("resource/export.vm", "UTF8"); } catch (ResourceNotFoundException rnfe) { rnfe.printStackTrace(); } catch (ParseErrorException pee) { pee.printStackTrace(); } catch (MethodInvocationException mie) { mie.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } StringWriter sw = new StringWriter(); template.merge(context, sw); fileInputStream = new ByteArrayInputStream(sw.toString().getBytes("UTF8")); // 记录操作日志 RapLog log = new RapLog(); log.setIp(org.apache.struts2.ServletActionContext.getRequest().getRemoteAddr()); log.setOperation("导出接口文档.项目名称:" + project.getName()); log.setUserName(getAccountMgr().getUser(getCurUserId()).getName()); logMgr.createLog(log); return SUCCESS; }
@Nullable public static String newDocumentText(@NotNull final IpnbFilePanel ipnbPanel) { final IpnbFile ipnbFile = ipnbPanel.getIpnbFile(); if (ipnbFile == null) return null; for (IpnbEditablePanel panel : ipnbPanel.getIpnbPanels()) { if (panel.isModified()) { panel.updateCellSource(); } } final IpnbFileRaw fileRaw = new IpnbFileRaw(); fileRaw.metadata = ipnbFile.getMetadata(); if (ipnbFile.getNbformat() == 4) { for (IpnbCell cell : ipnbFile.getCells()) { fileRaw.cells.add(IpnbCellRaw.fromCell(cell, ipnbFile.getNbformat())); } } else { final IpnbWorksheet worksheet = new IpnbWorksheet(); worksheet.cells.clear(); for (IpnbCell cell : ipnbFile.getCells()) { worksheet.cells.add(IpnbCellRaw.fromCell(cell, ipnbFile.getNbformat())); } fileRaw.worksheets = new IpnbWorksheet[] {worksheet}; } final StringWriter stringWriter = new StringWriter(); final JsonWriter writer = new JsonWriter(stringWriter); writer.setIndent(" "); gson.toJson(fileRaw, fileRaw.getClass(), writer); return stringWriter.toString(); }
private void processIncomingPackets() { for (RSCPacket p : packetQueue.getPackets()) { IoSession session = p.getSession(); Player player = (Player) session.getAttachment(); if (player.getUsername() == null && p.getID() != 32 && p.getID() != 77 && p.getID() != 0) { final String ip = player.getCurrentIP(); IPBanManager.throttle(ip); continue; } PacketHandler handler = packetHandlers.get(p.getID()); player.ping(); if (handler != null) { try { handler.handlePacket(p, session); try { if (p.getID() != 5) { // String s = "[PACKET] " + // session.getRemoteAddress().toString().replace("/", // "") + " : " + p.getID()+ // " ["+handler.getClass().toString()+"]" + " : "+ // player.getUsername() + " : "; // for(Byte b : p.getData()) // s += b; // Logger.println(s); } } catch (Exception e) { e.printStackTrace(); } } catch (Exception e) { String s; StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw, true); e.printStackTrace(pw); pw.flush(); sw.flush(); s = sw.toString(); Logger.error( "Exception with p[" + p.getID() + "] from " + player.getUsername() + " [" + player.getCurrentIP() + "]: " + s); player.getActionSender().sendLogout(); player.destroy(false); } } else { Logger.error( "Unhandled packet from " + player.getCurrentIP() + ": " + p.getID() + "len: " + p.getLength()); } } }
@Test public void testExplainAsXml() { String sql = "select 1 + 2, 3 from (values (true))"; final RelNode rel = tester.convertSqlToRel(sql).rel; StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); RelXmlWriter planWriter = new RelXmlWriter(pw, SqlExplainLevel.EXPPLAN_ATTRIBUTES); rel.explain(planWriter); pw.flush(); TestUtil.assertEqualsVerbose( "<RelNode type=\"LogicalProject\">\n" + "\t<Property name=\"EXPR$0\">\n" + "\t\t+(1, 2)\t</Property>\n" + "\t<Property name=\"EXPR$1\">\n" + "\t\t3\t</Property>\n" + "\t<Inputs>\n" + "\t\t<RelNode type=\"LogicalValues\">\n" + "\t\t\t<Property name=\"tuples\">\n" + "\t\t\t\t[{ true }]\t\t\t</Property>\n" + "\t\t\t<Inputs/>\n" + "\t\t</RelNode>\n" + "\t</Inputs>\n" + "</RelNode>\n", Util.toLinux(sw.toString())); }
private void debugThrowable(Throwable problem) { if (problem != null) { if (problem instanceof Error) { debug("Error: ", problem.getMessage()); } else { debug("Exception: ", problem.getMessage()); } StringWriter stackTraceWriter = new StringWriter(); problem.printStackTrace(new PrintWriter(stackTraceWriter)); String trace = stackTraceWriter.toString(); try { BufferedReader reader = new BufferedReader(new StringReader(trace)); if (reader.ready()) { String traceLine = reader.readLine(); int counter = 0; while (reader.ready() && traceLine != null && (counter < stackLength)) { debug(traceLine); traceLine = reader.readLine(); counter++; } } } catch (Exception ioException) { error( "Serious error in LoggingTool while printing exception " + "stack trace: ", ioException.getMessage()); logger.debug(ioException); } Throwable cause = problem.getCause(); if (cause != null) { debug("Caused by: "); debugThrowable(cause); } } }
public static String stackTraceToString(Throwable e) { StringWriter sw = new StringWriter(); PrintWriter writer = new PrintWriter(sw); e.printStackTrace(writer); writer.close(); return sw.getBuffer().toString(); }
/** * Print a log entry in the knapsack style. * * @param bundle * @param sr * @param level * @param msg * @param throwable */ public static void doKnapsackLog( Bundle bundle, ServiceReference sr, int level, String msg, Throwable throwable) { if (dateFormatter == null) dateFormatter = new SimpleDateFormat(DEFAULT_DATE_FORMAT); StringBuilder sb = new StringBuilder(); sb.append(dateFormatter.format(new Date(System.currentTimeMillis()))); sb.append(' '); getLevelLabel(level, sb); sb.append(' '); sb.append(msg); sb.append(StringConstants.TAB); getBundleLabel(bundle, sb); // Check for an exception, if available display it. if (throwable != null) { sb.append(throwable.getMessage()); sb.append(StringConstants.CRLF); StringWriter sWriter = new StringWriter(); PrintWriter pw = new PrintWriter(sWriter); throwable.printStackTrace(pw); sb.append(sWriter.toString()); } System.out.println(sb.toString()); }
public <T> T sendRequest(Class<T> cls, Object request) throws WasabiNetClientException { StringWriter sw = new StringWriter(); String convertida = null; String received = null; try { marshaller.setWriter(sw); marshaller.marshal(request); convertida = new String(sw.getBuffer().toString().getBytes("UTF8"), "UTF8"); System.out.println(convertida); received = getData(serviceUrl, convertida); System.out.println("---" + received + "---"); unmarshaller.setClass(cls); return (T) unmarshaller.unmarshal(new StringReader(received)); } catch (IOException e) { throw new WasabiNetClientException("Error de lectura/escritura:" + e.getMessage()); } catch (MarshalException e) { e.printStackTrace(); throw new WasabiNetClientException( "Error al armar la respuesta:" + e.getMessage(), convertida, received); } catch (ValidationException e) { throw new WasabiNetClientException( "Error en la validacion de la respuesta:" + e.getMessage(), convertida, received); } // catch WasabiNetClientException -> Esta directamente salta al metodo que ha llamado a // sendrequest }
public String objectToXml(Object object) { String rtnStr = ""; try { JAXBContext jaxbContext = cachedJaxb.get(pkgName); if (jaxbContext == null) { jaxbContext = JAXBContext.newInstance(pkgName); cachedJaxb.put(pkgName, jaxbContext); } Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_ENCODING, BcConstants.ENCODING); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.setProperty(Marshaller.JAXB_FRAGMENT, false); Class docClazz = Class.forName(pkgName + ".Document"); Class ofClazz = Class.forName(pkgName + ".ObjectFactory"); Object factory = ofClazz.newInstance(); Method method = ofClazz.getDeclaredMethod("createDocument", docClazz); JAXBElement jaxbElement = (JAXBElement) method.invoke(factory, docClazz.cast(object)); StringWriter sw = new StringWriter(); marshaller.marshal(jaxbElement, sw); rtnStr = sw.toString(); // TODO remove the header in a better way: <?xml version="1.0" encoding="UTF-8" // standalone="yes"?> rtnStr = StringUtils.substringAfter(rtnStr, "?>").trim(); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(e); } return rtnStr; }
public Object execute(Environment environment) throws Exception { log.debug("handling job " + jobDbid + " exception: " + exception.getMessage()); // load the job from the db DbSession dbSession = environment.get(DbSession.class); if (dbSession == null) { throw new JbpmException("no job-session configured to handle job"); } JobImpl job = dbSession.get(JobImpl.class, jobDbid); // serialize the stack trace StringWriter sw = new StringWriter(); exception.printStackTrace(new PrintWriter(sw)); if (job != null) { // decrement the number of retries int decrementedRetries = job.getRetries() - 1; log.debug("decrementing retries to " + decrementedRetries + " for " + job); job.release(); job.setRetries(decrementedRetries); job.setException(sw.toString()); // notify the job executor after the transaction is completed Transaction transaction = environment.get(Transaction.class); JobExecutor jobExecutor = environment.get(JobExecutor.class); if ((transaction != null) && (jobExecutor != null)) { log.trace("registering job executor notifier with " + transaction); transaction.registerSynchronization(new JobAddedNotification(jobExecutor)); } } return null; }
@SuppressWarnings("unused") private String unzipBody(InputStream str) { InputStreamReader sr = null; StringWriter writer = null; GZIPInputStream gis = null; try { char[] buffer = new char[10240]; gis = new GZIPInputStream(str); sr = new InputStreamReader(gis, "UTF-8"); writer = new StringWriter(); for (int i = 0; (i = sr.read(buffer)) > 0; ) { writer.write(buffer, 0, i); } return writer.toString(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { try { if (writer != null) writer.close(); if (sr != null) sr.close(); if (gis != null) gis.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return null; }
public static final String format(Throwable toss) { StringWriter sw = new StringWriter(); // Improved nested exception handling PrintWriter pw = new PrintWriter(sw) { boolean stop = false; @Override public void print(String s) { if (s.startsWith("Caused by")) stop = true; else if (!s.startsWith(" ") && !s.startsWith("\t")) stop = false; if (!stop) super.print(s); } @Override public void println() { if (!stop) super.println(); } }; for (Throwable t = toss; t != null; ) { t.printStackTrace(pw); t = t.getCause(); if (t != null) pw.append("Caused by: "); } return sw.toString(); }
@Override public void consumeData(IloOplModel oplModel) throws IOException { StringWriter sw = new StringWriter(); OutputStream os = new WriterOutputStream(sw); super.exportarStream(oplModel, os); stringBuilder.append(sw.getBuffer()); }
@Test public void marshalling() throws Exception { MyInteger value = new MyInteger(1); // MyInteger cannot be marshalled because it // lacks @XmlRootElement. JAXBContext context = JAXBContext.newInstance(MyInteger.class); StringWriter writer = new StringWriter(); try { context.createMarshaller().marshal(value, writer); fail(); } catch (MarshalException ex) { // Expected. } // When MyInteger is wrapped by RootElementWrapper, // marshalling becomes possible. RootElementWrapper<MyInteger> w = new RootElementWrapper<MyInteger>(value); context = JAXBContext.newInstance(RootElementWrapper.class, MyInteger.class); writer = new StringWriter(); context.createMarshaller().marshal(w, writer); assertEquals(w, (context.createUnmarshaller().unmarshal(new StringReader(writer.toString())))); }
/** * Process an MXMLTextData - this will write a String representation of the tag into the * StringWriter passed in. This will strip out any databinding expressions from the String. This * will write out only CDATA and TEXT TextDatas Other kinds of text data are not output into the * resulting XML object. TODO: databinding - add the databinding expressions as children of the * MXMLXMLNode, and also record what the TODO: target expressions for those are (these are the * expressions to set the value in the XML object when the TODO: PropertyChange event fires). */ void processNode(MXMLTextData tag, StringWriter sw) { switch (tag.getTextType()) { case CDATA: // For CDATA, just write out the text sw.write(tag.getContent()); break; case TEXT: { IMXMLSingleDataBindingNode db = null; if ((db = parseBindingExpression(tag)) != null) { // do databinding stuff: // 1. Walk up parent chain to compute target expression // 2. Parse databinding expression // 3. Save off both those pieces of data for use during codegen databindings.add(generateBindingNode(tag, db)); if (!isOnlyTextChild(tag)) { // Write out an empty CDATA section, so the tag will have the right // number of text children for the binding to target. sw.write("<![CDATA[]]>"); } } else { sw.write(replaceBindingEscapes(tag.getContent())); } } break; // Everything else gets stripped out } }
public String readString() throws IOException { StringWriter result; result = new StringWriter(); writeTo(result); return result.toString(); }
@Test public void testLoginActionByAuthenticateOneTimeUser() throws Exception { String actionString = Action.Login.toString(); when(mockHttpServletRequest.getParameter(ServletUtil.ACTION)).thenReturn(actionString); when(mockHttpServletRequest.getParameter(ServletUtil.PROJECT)).thenReturn(projectString); // set AuthenticateOneTimeUser true prepareEnterAuthenticateOneTimeUser(true); String xmi = constructProjectsObjectsXmi(); doThrow( new org.talend.gwtadministrator.server.remoteconnection.ConnectionUtil .ResponseException(xmi)) .when(ConnectionUtil.class); ConnectionUtil.returnProjectAndUsers(anyString(), (User) any(), anyBoolean()); // RUN... defaultConnectionStrategy.execute(mockHttpServletRequest, mockHttpServletResponse); verifyNecessaryChecks(actionString); // verify called listAllProjects once verifyStatic(org.mockito.Mockito.times(1)); ConnectionUtil.returnProjectAndUsers(anyString(), (User) any(), anyBoolean()); PrintWriter writer = mockHttpServletResponse.getWriter(); writer.flush(); System.out.println(outStringWriter.toString()); // ASSERT... assertThat(outStringWriter.toString(), is("RESPONSE:" + xmi)); }
@Test public void testListProjectsActionByNormalUser() throws Exception { String actionString = Action.ListProjects.toString(); when(mockHttpServletRequest.getParameter(ServletUtil.ACTION)).thenReturn(actionString); // set AuthenticateOneTimeUser false prepareEnterAuthenticateOneTimeUser(false); User user = stubbingCheckUser(); String xmi = constructProjectsObjectsXmi(); doThrow( new org.talend.gwtadministrator.server.remoteconnection.ConnectionUtil .ResponseException(xmi)) .when(ConnectionUtil.class); ConnectionUtil.listAuthorizedProjects(user); // RUN... defaultConnectionStrategy.execute(mockHttpServletRequest, mockHttpServletResponse); verifyNecessaryChecks(actionString); verifyStatic(org.mockito.Mockito.times(1)); ConnectionUtil.checkUser(loginString, password, false); verifyStatic(org.mockito.Mockito.times(1)); ConnectionUtil.listAuthorizedProjects(user); PrintWriter writer = mockHttpServletResponse.getWriter(); writer.flush(); System.out.println(outStringWriter.toString()); // ASSERT... assertThat(outStringWriter.toString(), is("RESPONSE:" + xmi)); }
/** Play Monument Handler for the server */ @Override public void handle(HttpExchange exchange) throws IOException { exchange.getResponseHeaders().set("Content-type", "application/json"); try { int gameID = checkCookie(exchange); if (gameID == -1) { System.err.print("\nInvalid Cookie. Thowing Error"); throw new Exception("INVALID COOKIE!"); } Gson gson = new Gson(); StringWriter writer = new StringWriter(); IOUtils.copy(exchange.getRequestBody(), writer); shared.communication.toServer.moves.Monument_ move = gson.fromJson(writer.toString(), Monument_.class); server.commands.Monument command = new server.commands.Monument(gameID); command.setParams(move); command.execute(server); this.addCommand(command, gameID); exchange.sendResponseHeaders(HttpURLConnection.HTTP_OK, 0); OutputStreamWriter output = new OutputStreamWriter(exchange.getResponseBody()); output.write(server.getModel(gameID)); output.flush(); exchange.getResponseBody().close(); exchange.close(); } catch (Exception e) { exchange.sendResponseHeaders(HttpURLConnection.HTTP_BAD_REQUEST, -1); exchange.getResponseBody().close(); exchange.close(); } }
// --------------------------------------------------------------------------- private void writeCache() { try { Debug.print("Writing cache"); FileOutputStream fos = new FileOutputStream(m_cacheFile); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeObject(m_depCache); oos.writeInt(m_newModificationCache.size()); Iterator<String> it = m_newModificationCache.keySet().iterator(); while (it.hasNext()) { String key = it.next(); oos.writeUTF(key); oos.writeLong(m_newModificationCache.get(key)); } oos.close(); } catch (Exception e) { Debug.print(e.getMessage()); StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw)); Debug.print(sw.toString()); } }