List of usage examples for java.lang Long toHexString
public static String toHexString(long i)
From source file:org.dspace.identifier.DOIIdentifierProviderTest.java
@Test public void testStore_DOI_as_item_metadata() throws SQLException, AuthorizeException, IOException, IdentifierException, IllegalAccessException, WorkflowException { Item item = newItem();// ww w. j a va 2 s . c om String doi = DOI.SCHEME + PREFIX + "/" + NAMESPACE_SEPARATOR + Long.toHexString(new Date().getTime()); context.turnOffAuthorisationSystem(); provider.saveDOIToObject(context, item, doi); context.restoreAuthSystemState(); List<MetadataValue> metadata = itemService.getMetadata(item, DOIIdentifierProvider.MD_SCHEMA, DOIIdentifierProvider.DOI_ELEMENT, DOIIdentifierProvider.DOI_QUALIFIER, null); boolean result = false; for (MetadataValue id : metadata) { if (id.getValue().equals(doiService.DOIToExternalForm(doi))) { result = true; } } assertTrue("Cannot store DOI as item metadata value.", result); }
From source file:edu.ku.brc.af.core.UsageTracker.java
/** * Gets the installation ID that 'uniquely' identifies the running instance * from other installations.//ww w .jav a2 s. co m * * @return the installation ID string */ public synchronized static String getInstallId() { AppPreferences appPrefs = AppPreferences.getLocalPrefs(); if (appPrefs.isAvailable()) { // get the first part of the install ID String installIdStart = appPrefs.get("InstallIdStart", null); //$NON-NLS-1$ if (installIdStart == null) { // create a new ID start (this is the first time the app has run) Random r = new Random(System.currentTimeMillis()); UUID idStart = new UUID(r.nextLong(), r.nextLong()); installIdStart = idStart.toString(); appPrefs.put("InstallIdStart", installIdStart); //$NON-NLS-1$ } // get the last part of the install ID String installIdEnd = appPrefs.get("InstallIdEnd", null); //$NON-NLS-1$ File pluginRegFile = XMLHelper.getConfigDir("plugin_registry.xml"); //$NON-NLS-1$ long lastMod = pluginRegFile.lastModified(); String lastModString = Long.toHexString(lastMod); if (installIdEnd == null || !installIdEnd.equals(lastModString)) { // somebody must have copied this install to a new storage // reset the InstallIdEnd preference clearUsageStats(); appPrefs.put("InstallIdEnd", lastModString); //$NON-NLS-1$ installIdEnd = lastModString; } String installId = installIdStart + "--" + installIdEnd; //$NON-NLS-1$ return installId; } return null; }
From source file:io.warp10.standalone.StandaloneDeleteHandler.java
@Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { if (target.equals(Constants.API_ENDPOINT_DELETE)) { baseRequest.setHandled(true);/*from ww w . ja v a2s . c o m*/ } else { return; } // // CORS header // response.setHeader("Access-Control-Allow-Origin", "*"); long nano = System.nanoTime(); // // Extract DatalogRequest if specified // String datalogHeader = request.getHeader(Constants.getHeader(Configuration.HTTP_HEADER_DATALOG)); DatalogRequest dr = null; boolean forwarded = false; if (null != datalogHeader) { byte[] bytes = OrderPreservingBase64.decode(datalogHeader.getBytes(Charsets.US_ASCII)); if (null != datalogPSK) { bytes = CryptoUtils.unwrap(datalogPSK, bytes); } if (null == bytes) { response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Invalid Datalog header."); return; } TDeserializer deser = new TDeserializer(new TCompactProtocol.Factory()); try { dr = new DatalogRequest(); deser.deserialize(dr, bytes); } catch (TException te) { response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, te.getMessage()); return; } Map<String, String> labels = new HashMap<String, String>(); labels.put(SensisionConstants.SENSISION_LABEL_ID, new String( OrderPreservingBase64.decode(dr.getId().getBytes(Charsets.US_ASCII)), Charsets.UTF_8)); labels.put(SensisionConstants.SENSISION_LABEL_TYPE, dr.getType()); Sensision.update(SensisionConstants.CLASS_WARP_DATALOG_REQUESTS_RECEIVED, labels, 1); // // Check that the request query string matches the QS in the datalog request // if (!request.getQueryString().equals(dr.getDeleteQueryString())) { response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Invalid DatalogRequest."); return; } forwarded = true; } // // TODO(hbs): Extract producer/owner from token // String token = null != dr ? dr.getToken() : request.getHeader(Constants.getHeader(Configuration.HTTP_HEADER_TOKENX)); if (null == token) { response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Missing token."); return; } WriteToken writeToken; try { writeToken = Tokens.extractWriteToken(token); } catch (WarpScriptException ee) { ee.printStackTrace(); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ee.getMessage()); return; } String application = writeToken.getAppName(); String producer = Tokens.getUUID(writeToken.getProducerId()); String owner = Tokens.getUUID(writeToken.getOwnerId()); // // For delete operations, producer and owner MUST be equal // if (!producer.equals(owner)) { response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Invalid write token for deletion."); return; } Map<String, String> sensisionLabels = new HashMap<String, String>(); sensisionLabels.put(SensisionConstants.SENSISION_LABEL_PRODUCER, producer); long count = 0; long gts = 0; Throwable t = null; StringBuilder metas = new StringBuilder(); // // Extract start/end // String startstr = request.getParameter(Constants.HTTP_PARAM_START); String endstr = request.getParameter(Constants.HTTP_PARAM_END); // // Extract selector // String selector = request.getParameter(Constants.HTTP_PARAM_SELECTOR); String minage = request.getParameter(Constants.HTTP_PARAM_MINAGE); if (null != minage) { response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Standalone version does not support the '" + Constants.HTTP_PARAM_MINAGE + "' parameter in delete requests."); return; } boolean dryrun = null != request.getParameter(Constants.HTTP_PARAM_DRYRUN); File loggingFile = null; PrintWriter loggingWriter = null; // // Open the logging file if logging is enabled // if (null != loggingDir) { long nanos = null != dr ? dr.getTimestamp() : TimeSource.getNanoTime(); StringBuilder sb = new StringBuilder(); sb.append(Long.toHexString(nanos)); sb.insert(0, "0000000000000000", 0, 16 - sb.length()); sb.append("-"); if (null != dr) { sb.append(dr.getId()); } else { sb.append(datalogId); } sb.append("-"); sb.append(dtf.print(nanos / 1000000L)); sb.append(Long.toString(1000000L + (nanos % 1000000L)).substring(1)); sb.append("Z"); if (null == dr) { dr = new DatalogRequest(); dr.setTimestamp(nanos); dr.setType(Constants.DATALOG_DELETE); dr.setId(datalogId); dr.setToken(token); dr.setDeleteQueryString(request.getQueryString()); } if (null != dr && (!forwarded || (forwarded && this.logforwarded))) { // // Serialize the request // TSerializer ser = new TSerializer(new TCompactProtocol.Factory()); byte[] encoded; try { encoded = ser.serialize(dr); } catch (TException te) { response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, te.getMessage()); return; } if (null != this.datalogPSK) { encoded = CryptoUtils.wrap(this.datalogPSK, encoded); } encoded = OrderPreservingBase64.encode(encoded); loggingFile = new File(loggingDir, sb.toString()); loggingWriter = new PrintWriter(new FileWriterWithEncoding(loggingFile, Charsets.UTF_8)); // // Write request // loggingWriter.println(new String(encoded, Charsets.US_ASCII)); } } boolean validated = false; try { if (null == producer || null == owner) { response.sendError(HttpServletResponse.SC_FORBIDDEN, "Invalid token."); return; } // // Build extra labels // Map<String, String> extraLabels = new HashMap<String, String>(); // // Only set owner and potentially app, producer may vary // extraLabels.put(Constants.OWNER_LABEL, owner); // FIXME(hbs): remove me if (null != application) { extraLabels.put(Constants.APPLICATION_LABEL, application); sensisionLabels.put(SensisionConstants.SENSISION_LABEL_APPLICATION, application); } boolean hasRange = false; long start = Long.MIN_VALUE; long end = Long.MAX_VALUE; if (null != startstr) { if (null == endstr) { response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Both " + Constants.HTTP_PARAM_START + " and " + Constants.HTTP_PARAM_END + " should be defined."); return; } if (startstr.contains("T")) { start = fmt.parseDateTime(startstr).getMillis() * Constants.TIME_UNITS_PER_MS; } else { start = Long.valueOf(startstr); } } if (null != endstr) { if (null == startstr) { response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Both " + Constants.HTTP_PARAM_START + " and " + Constants.HTTP_PARAM_END + " should be defined."); return; } if (endstr.contains("T")) { end = fmt.parseDateTime(endstr).getMillis() * Constants.TIME_UNITS_PER_MS; } else { end = Long.valueOf(endstr); } } if (Long.MIN_VALUE == start && Long.MAX_VALUE == end && null == request.getParameter(Constants.HTTP_PARAM_DELETEALL)) { response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Parameter " + Constants.HTTP_PARAM_DELETEALL + " should be set when deleting a full range."); return; } if (Long.MIN_VALUE != start || Long.MAX_VALUE != end) { hasRange = true; } if (start > end) { response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Invalid time range specification."); return; } // // Extract the class and labels selectors // The class selector and label selectors are supposed to have // values which use percent encoding, i.e. explicit percent encoding which // might have been re-encoded using percent encoding when passed as parameter // // Matcher m = EgressFetchHandler.SELECTOR_RE.matcher(selector); if (!m.matches()) { response.sendError(HttpServletResponse.SC_BAD_REQUEST); return; } String classSelector = URLDecoder.decode(m.group(1), "UTF-8"); String labelsSelection = m.group(2); Map<String, String> labelsSelectors; try { labelsSelectors = GTSHelper.parseLabelsSelectors(labelsSelection); } catch (ParseException pe) { response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, pe.getMessage()); return; } validated = true; // // Force 'producer'/'owner'/'app' from token // labelsSelectors.putAll(extraLabels); List<Metadata> metadatas = null; List<String> clsSels = new ArrayList<String>(); List<Map<String, String>> lblsSels = new ArrayList<Map<String, String>>(); clsSels.add(classSelector); lblsSels.add(labelsSelectors); metadatas = directoryClient.find(clsSels, lblsSels); response.setStatus(HttpServletResponse.SC_OK); response.setContentType("text/plain"); PrintWriter pw = response.getWriter(); StringBuilder sb = new StringBuilder(); for (Metadata metadata : metadatas) { // // Remove from DB // if (!hasRange) { if (!dryrun) { this.directoryClient.unregister(metadata); } } // // Remove data // long localCount = 0; if (!dryrun) { localCount = this.storeClient.delete(writeToken, metadata, start, end); } count += localCount; sb.setLength(0); GTSHelper.metadataToString(sb, metadata.getName(), metadata.getLabels()); if (metadata.getAttributesSize() > 0) { GTSHelper.labelsToString(sb, metadata.getAttributes()); } else { sb.append("{}"); } pw.write(sb.toString()); pw.write("\r\n"); metas.append(sb); metas.append("\n"); gts++; // Log detailed metrics for this GTS owner and app Map<String, String> labels = new HashMap<>(); labels.put(SensisionConstants.SENSISION_LABEL_OWNER, metadata.getLabels().get(Constants.OWNER_LABEL)); labels.put(SensisionConstants.SENSISION_LABEL_APPLICATION, metadata.getLabels().get(Constants.APPLICATION_LABEL)); Sensision.update( SensisionConstants.SENSISION_CLASS_CONTINUUM_STANDALONE_DELETE_DATAPOINTS_PEROWNERAPP, labels, localCount); } } catch (Exception e) { t = e; throw e; } finally { if (null != loggingWriter) { Map<String, String> labels = new HashMap<String, String>(); labels.put(SensisionConstants.SENSISION_LABEL_ID, new String( OrderPreservingBase64.decode(dr.getId().getBytes(Charsets.US_ASCII)), Charsets.UTF_8)); labels.put(SensisionConstants.SENSISION_LABEL_TYPE, dr.getType()); Sensision.update(SensisionConstants.CLASS_WARP_DATALOG_REQUESTS_LOGGED, labels, 1); loggingWriter.close(); if (validated) { loggingFile.renameTo(new File(loggingFile.getAbsolutePath() + DatalogForwarder.DATALOG_SUFFIX)); } else { loggingFile.delete(); } } Sensision.update(SensisionConstants.SENSISION_CLASS_CONTINUUM_STANDALONE_DELETE_REQUESTS, sensisionLabels, 1); Sensision.update(SensisionConstants.SENSISION_CLASS_CONTINUUM_STANDALONE_DELETE_GTS, sensisionLabels, gts); Sensision.update(SensisionConstants.SENSISION_CLASS_CONTINUUM_STANDALONE_DELETE_DATAPOINTS, sensisionLabels, count); Sensision.update(SensisionConstants.SENSISION_CLASS_CONTINUUM_STANDALONE_DELETE_TIME_US, sensisionLabels, (System.nanoTime() - nano) / 1000); LoggingEvent event = LogUtil.setLoggingEventAttribute(null, LogUtil.DELETION_TOKEN, token); event = LogUtil.setLoggingEventAttribute(event, LogUtil.DELETION_SELECTOR, selector); event = LogUtil.setLoggingEventAttribute(event, LogUtil.DELETION_START, startstr); event = LogUtil.setLoggingEventAttribute(event, LogUtil.DELETION_END, endstr); event = LogUtil.setLoggingEventAttribute(event, LogUtil.DELETION_METADATA, metas.toString()); event = LogUtil.setLoggingEventAttribute(event, LogUtil.DELETION_COUNT, Long.toString(count)); event = LogUtil.setLoggingEventAttribute(event, LogUtil.DELETION_GTS, Long.toString(gts)); LogUtil.addHttpHeaders(event, request); if (null != t) { LogUtil.setLoggingEventStackTrace(null, LogUtil.STACK_TRACE, t); } LOG.info(LogUtil.serializeLoggingEvent(this.keyStore, event)); } response.setStatus(HttpServletResponse.SC_OK); }
From source file:org.opendaylight.vpnservice.alivenessmonitor.internal.AlivenessProtocolHandlerLLDP.java
public Ethernet makeLLDPPacket(String nodeId, long portNum, int serviceId, byte[] srcMac, String sourceInterface) { // Create LLDP TTL TLV LLDPTLV lldpTlvTTL = buildLLDTLV(LLDPTLV.TLVType.TTL, new byte[] { (byte) 0, (byte) 120 }); LLDPTLV lldpTlvChassisId = buildLLDTLV(LLDPTLV.TLVType.ChassisID, LLDPTLV.createChassisIDTLVValue(colonize(StringUtils .leftPad(Long.toHexString(MDSALUtil.getDpnIdFromNodeName(nodeId).longValue()), 16, "0")))); LLDPTLV lldpTlvSystemName = buildLLDTLV(TLVType.SystemName, LLDPTLV.createSystemNameTLVValue(nodeId)); LLDPTLV lldpTlvPortId = buildLLDTLV(TLVType.PortID, LLDPTLV.createPortIDTLVValue(Long.toHexString(portNum))); String customValue = sourceInterface + "#" + getPacketId(); LOG.debug("Sending LLDP packet, custome value " + customValue); LLDPTLV lldpTlvCustom = buildLLDTLV(TLVType.Custom, customValue.getBytes()); List<LLDPTLV> lstLLDPTLVCustom = new ArrayList<>(); lstLLDPTLVCustom.add(lldpTlvCustom); LLDP lldpDiscoveryPacket = new LLDP(); lldpDiscoveryPacket.setChassisId(lldpTlvChassisId).setPortId(lldpTlvPortId).setTtl(lldpTlvTTL) .setSystemNameId(lldpTlvSystemName).setOptionalTLVList(lstLLDPTLVCustom); byte[] destMac = LLDP.LLDPMulticastMac; Ethernet ethernetPacket = new Ethernet(); ethernetPacket.setSourceMACAddress(srcMac).setDestinationMACAddress(destMac) .setEtherType(EtherTypes.LLDP.shortValue()).setPayload(lldpDiscoveryPacket); return ethernetPacket; }
From source file:com.shvet.poi.util.HexDump.java
private static String xpad(long value, int pad, String prefix) { String sv = Long.toHexString(value).toUpperCase(Locale.ROOT); int len = sv.length(); if ((pad == 0 || len == pad) && "".equals(prefix)) return sv; StringBuilder sb = new StringBuilder(prefix); if (len < pad) { sb.append("0000000000000000", 0, pad - len); sb.append(sv);//from ww w . j ava 2 s .co m } else if (len > pad) { sb.append(sv, len - pad, len); } else { sb.append(sv); } return sb.toString(); }
From source file:bookkeepr.xmlable.DatabaseManager.java
public synchronized void restore() { Logger.getLogger(DatabaseManager.class.getName()).log(Level.INFO, "Restoring from " + rootPath.getAbsolutePath()); long[] count = new long[256]; Arrays.fill(count, 0);// www . j av a 2s.co m File[] dirList = rootPath.listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { return name.endsWith(".xml.gz"); } }); Arrays.sort(dirList, new Comparator<File>() { public int compare(File o1, File o2) { return String.CASE_INSENSITIVE_ORDER.compare(o1.getName(), o2.getName()); } }); for (File f : dirList) { try { Index<IdAble> idx = (Index<IdAble>) XMLReader.read(new GZIPInputStream(new FileInputStream(f))); List<IdAble> list = idx.getIndex(); if (idx.getIndex().size() < 1) { continue;// it's an empty list! } String key = getKey(list.get(0).getId()); IdAble last = list.get(list.size() - 1); int type = getType(last); int origin = getOrigin(last); if (origin > this.maxOriginId) { this.maxOriginId = origin; } if (last.getId() > latestIds[origin][type]) { latestIds[origin][type] = last.getId(); } this.indicies.put(key, idx); count[this.getType(list.get(0))] += idx.getSize(); // notify listeners. for (IdAble item : idx.getIndex()) { for (Object listener : listeners[this.getType(item)]) { ((ChangeListener) listener).itemUpdated(this, item, this.getOrigin(item) != this.originId, false); } } } catch (SAXException ex) { Logger.getLogger(DatabaseManager.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(DatabaseManager.class.getName()).log(Level.SEVERE, null, ex); } } for (int type = 0; type < 256; type++) { long latest = latestIds[this.getOriginId()][type] & 0x00000FFFFFFFFFFFL; if (latest >= this.nextId[type]) { this.nextId[type] = latest + 1; Logger.getLogger(DatabaseManager.class.getName()).log(Level.WARNING, "Latest index for type " + Integer.toHexString(type) + " is later than our next ID... Updating next ID to avoid database conflicts (latest is: " + Long.toHexString(latest) + ")"); } } Logger.getLogger(DatabaseManager.class.getName()).log(Level.INFO, "Loaded " + this.indicies.size() + " indexes"); for (int t = 0; t < count.length; t++) { if (count[t] > 0) { Logger.getLogger(DatabaseManager.class.getName()).log(Level.INFO, "Loaded " + count[t] + " items of type " + Integer.toHexString(t)); } } }
From source file:de.uzk.hki.da.format.PublishImageConversionStrategy.java
/** * Adds a Text Watermark to the operation. * * @param commandAsList the command as list * @param audience the audience//from ww w. j av a2 s. co m * @return the watermark * @author Jens Peters */ private ArrayList<String> assembleWatermarkCommand(ArrayList<String> commandAsList, String audience) { if (getPublicationRightForAudience(audience) == null) return commandAsList; if (getPublicationRightForAudience(audience).getImageRestriction() == null) return commandAsList; String text = getPublicationRightForAudience(audience).getImageRestriction().getWatermarkString(); if (text == null || text.equals("")) { logger.debug("Adding Watermark: text not found for audience " + audience); return commandAsList; } String psize = getPublicationRightForAudience(audience).getImageRestriction().getWatermarkPointSize(); if (psize == null) { logger.debug("Adding watermark: point size not found for audience " + audience); throw new UserException(UserExceptionId.WATERMARK_NO_POINTSIZE, "No setting for pointsize given while adding watermark"); } String position = getPublicationRightForAudience(audience).getImageRestriction().getWatermarkPosition(); if (position == null) { logger.debug("Adding watermark: gravity not found for audience " + audience); throw new UserException(UserExceptionId.WATERMARK_NO_GRAVITY, "No setting for gravity given while adding watermark"); } String opacity = getPublicationRightForAudience(audience).getImageRestriction().getWatermarkOpacity(); if (opacity == null) { logger.debug("Adding watermark: opacity not found for audience " + audience); throw new UserException(UserExceptionId.WATERMARK_NO_OPACITY, "No setting for opacity given while adding watermark"); } String opacityHex = Long.toHexString(Math.round(Integer.parseInt(opacity) * 2.55)); if (opacityHex.length() == 1) opacityHex = "0" + opacityHex; commandAsList.add("-font"); commandAsList.add("Arial"); commandAsList.add("-pointsize"); commandAsList.add(psize); commandAsList.add("-draw"); commandAsList.add("gravity " + position + " fill #000000" + opacityHex + " text 0,15 '" + text + "' fill #ffffff" + opacityHex + " text 0,14 '" + text + "'"); return commandAsList; }
From source file:org.apache.solr.servlet.cache.HttpCacheHeaderUtil.java
/** * Checks if the downstream request handler wants to avoid HTTP caching of * the response./*ww w . ja va2s .co m*/ * * @param solrRsp The Solr response object * @param resp The HTTP servlet response object * @param reqMethod The HTTP request type */ public static void checkHttpCachingVeto(final SolrQueryResponse solrRsp, HttpServletResponse resp, final Method reqMethod) { // For POST we do nothing. They never get cached if (Method.POST == reqMethod || Method.OTHER == reqMethod) { return; } // If the request handler has not vetoed and there is no // exception silently return if (solrRsp.isHttpCaching() && solrRsp.getException() == null) { return; } // Otherwise we tell the caches that we don't want to cache the response resp.setHeader("Cache-Control", "no-cache, no-store"); // For HTTP/1.0 proxy caches resp.setHeader("Pragma", "no-cache"); // This sets the expiry date to a date in the past // As long as no time machines get invented this is safe resp.setHeader("Expires", "Sat, 01 Jan 2000 01:00:00 GMT"); // We signal "just modified" just in case some broken // proxy cache does not follow the above headers resp.setDateHeader("Last-Modified", System.currentTimeMillis()); // We override the ETag with something different resp.setHeader("ETag", '"' + Long.toHexString(System.currentTimeMillis()) + '"'); }
From source file:com.yifanlu.PSXperiaTool.Extractor.CrashBandicootExtractor.java
private void patchEmulator() throws IOException { Logger.info("Verifying the emulator binary."); Properties config = new Properties(); config.loadFromXML(new FileInputStream(new File(mOutputDir, "/config/config.xml"))); String emulatorName = config.getProperty("emulator_name", "libjava-activity.so"); File origEmulator = new File(mOutputDir, "/lib/armeabi/" + emulatorName); String emulatorCRC32 = Long.toHexString(FileUtils.checksumCRC32(origEmulator)); if (!emulatorCRC32.equalsIgnoreCase(config.getProperty("emulator_crc32"))) throw new UnsupportedOperationException( "The emulator checksum is invalid. Cannot patch. CRC32: " + emulatorCRC32); File newEmulator = new File(mOutputDir, "/lib/armeabi/libjava-activity-patched.so"); File emulatorPatch = new File(mOutputDir, "/config/" + config.getProperty("emulator_patch", "")); if (emulatorPatch.equals("")) { Logger.info("No patch needed."); FileUtils.moveFile(origEmulator, newEmulator); } else {// w w w.j a v a 2 s . com Logger.info("Patching emulator."); newEmulator.createNewFile(); JBPatch.bspatch(origEmulator, newEmulator, emulatorPatch); emulatorPatch.delete(); } FileUtils.copyInputStreamToFile( PSXperiaTool.class.getResourceAsStream("/resources/libjava-activity-wrapper.so"), origEmulator); }
From source file:MimeUtil.java
/** * Creates a new unique message boundary string that can be used as boundary * parameter for the Content-Type header field of a message. * /* ww w .j a v a 2s . com*/ * @return a new unique message boundary string. */ public static String createUniqueBoundary() { StringBuilder sb = new StringBuilder(); sb.append("-=Part."); sb.append(Integer.toHexString(nextCounterValue())); sb.append('.'); sb.append(Long.toHexString(random.nextLong())); sb.append('.'); sb.append(Long.toHexString(System.currentTimeMillis())); sb.append('.'); sb.append(Long.toHexString(random.nextLong())); sb.append("=-"); return sb.toString(); }