/** * Starts a native process on the server * * @param command the command to start the process * @param dir the dir in which the process starts */ static String startProcess(String command, String dir) throws IOException { StringBuffer ret = new StringBuffer(); String[] comm = new String[3]; comm[0] = COMMAND_INTERPRETER[0]; comm[1] = COMMAND_INTERPRETER[1]; comm[2] = command; long start = System.currentTimeMillis(); try { // Start process Process ls_proc = Runtime.getRuntime().exec(comm, null, new File(dir)); // Get input and error streams BufferedInputStream ls_in = new BufferedInputStream(ls_proc.getInputStream()); BufferedInputStream ls_err = new BufferedInputStream(ls_proc.getErrorStream()); boolean end = false; while (!end) { int c = 0; while ((ls_err.available() > 0) && (++c <= 1000)) { ret.append(conv2Html(ls_err.read())); } c = 0; while ((ls_in.available() > 0) && (++c <= 1000)) { ret.append(conv2Html(ls_in.read())); } try { ls_proc.exitValue(); // if the process has not finished, an exception is thrown // else while (ls_err.available() > 0) ret.append(conv2Html(ls_err.read())); while (ls_in.available() > 0) ret.append(conv2Html(ls_in.read())); end = true; } catch (IllegalThreadStateException ex) { // Process is running } // The process is not allowed to run longer than given time. if (System.currentTimeMillis() - start > MAX_PROCESS_RUNNING_TIME) { ls_proc.destroy(); end = true; ret.append("!!!! Process has timed out, destroyed !!!!!"); } try { Thread.sleep(50); } catch (InterruptedException ie) { } } } catch (IOException e) { ret.append("Error: " + e); } return ret.toString(); }
/** * main method * * <p>This uses the system properties: * * <ul> * <li><code>rjava.path</code> : path of the rJava package * <li><code>rjava.lib</code> : lib sub directory of the rJava package * <li><code>main.class</code> : main class to "boot", assumes Main if not specified * <li><code>rjava.class.path</code> : set of paths to populate the initiate the class path * </ul> * * <p>and boots the "main" method of the specified <code>main.class</code>, passing the args down * to the booted class * * <p>This makes sure R and rJava are known by the class loader */ public static void main(String[] args) { String rJavaPath = System.getProperty("rjava.path"); if (rJavaPath == null) { System.err.println("ERROR: rjava.path is not set"); System.exit(2); } String rJavaLib = System.getProperty("rjava.lib"); if (rJavaLib == null) { // it is not really used so far, just for rJava.so, so we can guess rJavaLib = rJavaPath + File.separator + "libs"; } RJavaClassLoader cl = new RJavaClassLoader(u2w(rJavaPath), u2w(rJavaLib)); String mainClass = System.getProperty("main.class"); if (mainClass == null || mainClass.length() < 1) { System.err.println("WARNING: main.class not specified, assuming 'Main'"); mainClass = "Main"; } String classPath = System.getProperty("rjava.class.path"); if (classPath != null) { StringTokenizer st = new StringTokenizer(classPath, File.pathSeparator); while (st.hasMoreTokens()) { String dirname = u2w(st.nextToken()); cl.addClassPath(dirname); } } try { cl.bootClass(mainClass, "main", args); } catch (Exception ex) { System.err.println("ERROR: while running main method: " + ex); ex.printStackTrace(); } }
/** Creates a new JAR file. */ void create(OutputStream out, Manifest manifest) throws IOException { ZipOutputStream zos = new JarOutputStream(out); if (flag0) { zos.setMethod(ZipOutputStream.STORED); } if (manifest != null) { if (vflag) { output(getMsg("out.added.manifest")); } ZipEntry e = new ZipEntry(MANIFEST_DIR); e.setTime(System.currentTimeMillis()); e.setSize(0); e.setCrc(0); zos.putNextEntry(e); e = new ZipEntry(MANIFEST_NAME); e.setTime(System.currentTimeMillis()); if (flag0) { crc32Manifest(e, manifest); } zos.putNextEntry(e); manifest.write(zos); zos.closeEntry(); } for (File file : entries) { addFile(zos, file); } zos.close(); }
/** * Constructor. The first time an RJavaClassLoader is created, it is cached as the primary loader. * * @param path path of the rJava package * @param libpath lib sub directory of the rJava package */ public RJavaClassLoader(String path, String libpath) { super(new URL[] {}); // respect rJava.debug level String rjd = System.getProperty("rJava.debug"); if (rjd != null && rjd.length() > 0 && !rjd.equals("0")) verbose = true; if (verbose) System.out.println("RJavaClassLoader(\"" + path + "\",\"" + libpath + "\")"); if (primaryLoader == null) { primaryLoader = this; if (verbose) System.out.println(" - primary loader"); } else { if (verbose) System.out.println(" - NOT primrary (this=" + this + ", primary=" + primaryLoader + ")"); } libMap = new HashMap /*<String,UnixFile>*/(); classPath = new Vector /*<UnixFile>*/(); classPath.add(new UnixDirectory(path + "/java")); rJavaPath = path; rJavaLibPath = libpath; /* load the rJava library */ UnixFile so = new UnixFile(rJavaLibPath + "/rJava.so"); if (!so.exists()) so = new UnixFile(rJavaLibPath + "/rJava.dll"); if (so.exists()) libMap.put("rJava", so); /* load the jri library */ UnixFile jri = new UnixFile(path + "/jri/libjri.so"); String rarch = System.getProperty("r.arch"); if (rarch != null && rarch.length() > 0) { UnixFile af = new UnixFile(path + "/jri" + rarch + "/libjri.so"); if (af.exists()) jri = af; else { af = new UnixFile(path + "/jri" + rarch + "/jri.dll"); if (af.exists()) jri = af; } } if (!jri.exists()) jri = new UnixFile(path + "/jri/libjri.jnilib"); if (!jri.exists()) jri = new UnixFile(path + "/jri/jri.dll"); if (jri.exists()) { libMap.put("jri", jri); if (verbose) System.out.println(" - registered JRI: " + jri); } /* if we are the primary loader, make us the context loader so projects that rely on the context loader pick us */ if (primaryLoader == this) Thread.currentThread().setContextClassLoader(this); if (verbose) { System.out.println("RJavaClassLoader initialized.\n\nRegistered libraries:"); for (Iterator entries = libMap.keySet().iterator(); entries.hasNext(); ) { Object key = entries.next(); System.out.println(" " + key + ": '" + libMap.get(key) + "'"); } System.out.println("\nRegistered class paths:"); for (Enumeration e = classPath.elements(); e.hasMoreElements(); ) System.out.println(" '" + e.nextElement() + "'"); System.out.println("\n-- end of class loader report --"); } }
private void addCreatedBy(Manifest m) { Attributes global = m.getMainAttributes(); if (global.getValue(new Attributes.Name("Created-By")) == null) { String javaVendor = System.getProperty("java.vendor"); String jdkVersion = System.getProperty("java.version"); global.put(new Attributes.Name("Created-By"), jdkVersion + " (" + javaVendor + ")"); } }
// -creatediff -applydiff -debug -output file public static void main(String[] args) throws IOException { boolean diff = true; boolean minimal = true; String outputFile = "out.jardiff"; for (int counter = 0; counter < args.length; counter++) { // for backward compatibilty with 1.0.1/1.0 if (args[counter].equals("-nonminimal") || args[counter].equals("-n")) { minimal = false; } else if (args[counter].equals("-creatediff") || args[counter].equals("-c")) { diff = true; } else if (args[counter].equals("-applydiff") || args[counter].equals("-a")) { diff = false; } else if (args[counter].equals("-debug") || args[counter].equals("-d")) { _debug = true; } else if (args[counter].equals("-output") || args[counter].equals("-o")) { if (++counter < args.length) { outputFile = args[counter]; } } else if (args[counter].equals("-applydiff") || args[counter].equals("-a")) { diff = false; } else { if ((counter + 2) != args.length) { showHelp(); System.exit(0); } if (diff) { try { OutputStream os = new FileOutputStream(outputFile); JarDiff.createPatch(args[counter], args[counter + 1], os, minimal); os.close(); } catch (IOException ioe) { try { System.out.println(getResources().getString("jardiff.error.create") + " " + ioe); } catch (MissingResourceException mre) { } } } else { try { OutputStream os = new FileOutputStream(outputFile); new JarDiffPatcher().applyPatch(null, args[counter], args[counter + 1], os); os.close(); } catch (IOException ioe) { try { System.out.println(getResources().getString("jardiff.error.apply") + " " + ioe); } catch (MissingResourceException mre) { } } } System.exit(0); } } showHelp(); }
public Graph(WeightedBVGraph graph, String[] names) { org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger("it.unimi.dsi.webgraph.ImmutableGraph"); logger.setLevel(org.apache.log4j.Level.FATAL); if (names.length != graph.numNodes()) throw new Error("Problem with the list of names for the nodes in the graph."); try { File auxFile = File.createTempFile("graph-maps-" + System.currentTimeMillis(), "aux"); auxFile.deleteOnExit(); RecordManager recMan = RecordManagerFactory.createRecordManager(auxFile.getAbsolutePath()); nodes = recMan.hashMap("nodes"); nodesReverse = recMan.hashMap("nodesReverse"); } catch (IOException ex) { throw new Error(ex); } nodes.clear(); nodesReverse.clear(); Constructor[] cons = WeightedArc.class.getDeclaredConstructors(); for (int i = 0; i < cons.length; i++) cons[i].setAccessible(true); this.graph = graph; WeightedArcSet list = new WeightedArcSet(); ArcLabelledNodeIterator it = graph.nodeIterator(); while (it.hasNext()) { if (commit++ % COMMIT_SIZE == 0) { commit(); list.commit(); } Integer aux1 = it.nextInt(); Integer aux2 = null; ArcLabelledNodeIterator.LabelledArcIterator suc = it.successors(); while ((aux2 = suc.nextInt()) != null && aux2 >= 0 && (aux2 < graph.numNodes())) try { WeightedArc arc = (WeightedArc) cons[0].newInstance(aux2, aux1, suc.label().getFloat()); list.add(arc); this.nodes.put(aux1, names[aux1]); this.nodes.put(aux2, names[aux2]); this.nodesReverse.put(names[aux1], aux1); this.nodesReverse.put(names[aux2], aux2); } catch (Exception ex) { throw new Error(ex); } } reverse = new WeightedBVGraph(list.toArray(new WeightedArc[0])); numArcs = list.size(); iterator = nodeIterator(); try { File auxFile = File.createTempFile("graph" + System.currentTimeMillis(), "aux"); auxFile.deleteOnExit(); String basename = auxFile.getAbsolutePath(); store(basename); } catch (IOException ex) { throw new Error(ex); } commit(); }
public static void main(String[] args) throws IOException { System.out.println("Input Stream:"); long start = System.currentTimeMillis(); Path filename = Paths.get(args[0]); long crcValue = checksumInputStream(filename); long end = System.currentTimeMillis(); System.out.println(Long.toHexString(crcValue)); System.out.println((end - start) + " milliseconds"); System.out.println("Buffered Input Stream:"); start = System.currentTimeMillis(); crcValue = checksumBufferedInputStream(filename); end = System.currentTimeMillis(); System.out.println(Long.toHexString(crcValue)); System.out.println((end - start) + " milliseconds"); System.out.println("Random Access File:"); start = System.currentTimeMillis(); crcValue = checksumRandomAccessFile(filename); end = System.currentTimeMillis(); System.out.println(Long.toHexString(crcValue)); System.out.println((end - start) + " milliseconds"); System.out.println("Mapped File:"); start = System.currentTimeMillis(); crcValue = checksumMappedFile(filename); end = System.currentTimeMillis(); System.out.println(Long.toHexString(crcValue)); System.out.println((end - start) + " milliseconds"); }
private void updateLinuxServiceInstaller() { try { File dir = new File(directory, "CTP"); if (suppressFirstPathElement) dir = dir.getParentFile(); Properties props = new Properties(); String ctpHome = dir.getAbsolutePath(); cp.appendln(Color.black, "...CTP_HOME: " + ctpHome); ctpHome = ctpHome.replaceAll("\\\\", "\\\\\\\\"); props.put("CTP_HOME", ctpHome); File javaHome = new File(System.getProperty("java.home")); String javaBin = (new File(javaHome, "bin")).getAbsolutePath(); cp.appendln(Color.black, "...JAVA_BIN: " + javaBin); javaBin = javaBin.replaceAll("\\\\", "\\\\\\\\"); props.put("JAVA_BIN", javaBin); File linux = new File(dir, "linux"); File install = new File(linux, "ctpService-ubuntu.sh"); cp.appendln(Color.black, "Linux service installer:"); cp.appendln(Color.black, "...file: " + install.getAbsolutePath()); String bat = getFileText(install); bat = replace(bat, props); // do the substitutions bat = bat.replace("\r", ""); setFileText(install, bat); // If this is an ISN installation, put the script in the correct place. String osName = System.getProperty("os.name").toLowerCase(); if (programName.equals("ISN") && !osName.contains("windows")) { install = new File(linux, "ctpService-red.sh"); cp.appendln(Color.black, "ISN service installer:"); cp.appendln(Color.black, "...file: " + install.getAbsolutePath()); bat = getFileText(install); bat = replace(bat, props); // do the substitutions bat = bat.replace("\r", ""); File initDir = new File("/etc/init.d"); File initFile = new File(initDir, "ctpService"); if (initDir.exists()) { setOwnership(initDir, "edge", "edge"); setFileText(initFile, bat); initFile.setReadable(true, false); // everybody can read //Java 1.6 initFile.setWritable(true); // only the owner can write //Java 1.6 initFile.setExecutable(true, false); // everybody can execute //Java 1.6 } } } catch (Exception ex) { ex.printStackTrace(); System.err.println("Unable to update the Linux service ctpService.sh file"); } }
public boolean avrdude(Collection params) throws RunnerException { List commandDownloader = new ArrayList(); commandDownloader.add("avrdude"); // Point avrdude at its config file since it's in a non-standard location. if (Base.isMacOS()) { commandDownloader.add("-C" + "hardware/tools/avr/etc/avrdude.conf"); } else if (Base.isWindows()) { String userdir = System.getProperty("user.dir") + File.separator; commandDownloader.add("-C" + userdir + "hardware/tools/avr/etc/avrdude.conf"); } else { // ???: is it better to have Linux users install avrdude themselves, in // a way that it can find its own configuration file? commandDownloader.add("-C" + "hardware/tools/avrdude.conf"); } if (Preferences.getBoolean("upload.verbose")) { commandDownloader.add("-v"); commandDownloader.add("-v"); commandDownloader.add("-v"); commandDownloader.add("-v"); } else { commandDownloader.add("-q"); commandDownloader.add("-q"); } // XXX: quick hack to chop the "atmega" off of "atmega8" and "atmega168", // then shove an "m" at the beginning. won't work for attiny's, etc. commandDownloader.add( "-pm" + Preferences.get("boards." + Preferences.get("board") + ".build.mcu").substring(6)); commandDownloader.addAll(params); return executeUploadCommand(commandDownloader); }
/** @throws Exception If failed. */ public void testAntGarTaskToString() throws Exception { String tmpDirName = GridTestProperties.getProperty("ant.gar.tmpdir"); String srcDirName = GridTestProperties.getProperty("ant.gar.srcdir"); String baseDirName = tmpDirName + File.separator + System.currentTimeMillis() + "_6"; String metaDirName = baseDirName + File.separator + "META-INF"; String garFileName = baseDirName + ".gar"; // Make base and META-INF dir. boolean mkdir = new File(baseDirName).mkdirs(); assert mkdir; mkdir = new File(metaDirName).mkdirs(); assert mkdir; // Copy files to basedir U.copy(new File(srcDirName), new File(baseDirName), true); IgniteDeploymentGarAntTask garTask = new IgniteDeploymentGarAntTask(); Project garProject = new Project(); garProject.setName("Gar test project"); garTask.setDestFile(new File(garFileName)); garTask.setBasedir(new File(garFileName)); garTask.setProject(garProject); garTask.setDescrdir(new File(garFileName)); garTask.toString(); }
public static void LoadApplication(Context context, String runtimeDataDir, String[] apks) { synchronized (lock) { if (!initialized) { System.loadLibrary("monodroid"); Locale locale = Locale.getDefault(); String language = locale.getLanguage() + "-" + locale.getCountry(); String filesDir = context.getFilesDir().getAbsolutePath(); String cacheDir = context.getCacheDir().getAbsolutePath(); String dataDir = context.getApplicationInfo().dataDir + "/lib"; ClassLoader loader = context.getClassLoader(); Runtime.init( language, apks, runtimeDataDir, new String[] { filesDir, cacheDir, dataDir, }, loader, new java.io.File( android.os.Environment.getExternalStorageDirectory(), "Android/data/" + context.getPackageName() + "/files/.__override__") .getAbsolutePath(), MonoPackageManager_Resources.Assemblies); initialized = true; } } }
public String getTimeElapsed() { long time = (System.currentTimeMillis() - starttime) / 1000l; if (time - 60l >= 0) { if (time % 60 >= 10) return time / 60 + ":" + (time % 60) + "m"; else return time / 60 + ":0" + (time % 60) + "m"; } else return time < 10 ? "0" + time + "s" : time + "s"; }
public String getUprate() { long time = System.currentTimeMillis() - starttime; if (time != 0) { long uprate = currSize * 1000 / time; return convertFileSize(uprate) + "/s"; } else return "n/a"; }
private static darwin.jopenctm.data.Mesh convertMesh(Mesh mesh, String matName) throws IOException { // standard checks VertexBuffer vbuffer = mesh.getVertices(); int vc = mesh.getVertexCount(); if (!vbuffer.layout.hasElement(POSITION)) { throw new IOException("The mesh doesn't have a float3 vertex position attribute!"); } if (mesh.getPrimitiv_typ() != GL.GL_TRIANGLES) { throw new IOException("The CTM File Format only supports triangle Meshes"); } // create indicie array int[] meshIndicies = mesh.getIndicies(); if (meshIndicies == null) { throw new IOException("Only meshes with indices can be exported!"); } int[] indices = new int[mesh.getIndexCount()]; System.arraycopy(meshIndicies, 0, indices, 0, indices.length); AttributeData[] atts = createAttributeData(vbuffer); // create position array float[] vertices = new float[vc * CTM_POSITION_ELEMENT_COUNT]; int i = 0; for (Vertex v : vbuffer) { copyToBuffer(vertices, i, v, POSITION); i += CTM_POSITION_ELEMENT_COUNT; } // create optional normal array float[] normals = null; if (vbuffer.layout.hasElement(NORMAL)) { normals = new float[vc * CTM_NORMAL_ELEMENT_COUNT]; int k = 0; for (Vertex v : vbuffer) { copyToBuffer(normals, k, v, NORMAL); k += CTM_NORMAL_ELEMENT_COUNT; } } // create uv arrays boolean hasUV = vbuffer.layout.hasElement(TEX_COORD); AttributeData[] texcoords = new AttributeData[hasUV ? 1 : 0]; if (hasUV) { float[] values = new float[vc * CTM_UV_ELEMENT_COUNT]; int k = 0; for (Vertex v : vbuffer) { copyToBuffer(values, k, v, TEX_COORD); k += CTM_UV_ELEMENT_COUNT; } texcoords[0] = new AttributeData("TexCoord", matName, AttributeData.STANDARD_UV_PRECISION, values); } return new darwin.jopenctm.data.Mesh(vertices, normals, indices, texcoords, atts); }
public ExtMXSerializer getResXmlSerializer() { ExtMXSerializer serial = new ExtMXSerializer(); serial.setProperty(ExtXmlSerializer.PROPERTY_SERIALIZER_INDENTATION, " "); serial.setProperty( ExtXmlSerializer.PROPERTY_SERIALIZER_LINE_SEPARATOR, System.getProperty("line.separator")); serial.setProperty(ExtMXSerializer.PROPERTY_DEFAULT_ENCODING, "utf-8"); serial.setDisabledAttrEscape(true); return serial; }
/** adds an entry to the class path */ public void addClassPath(String cp) { UnixFile f = new UnixFile(cp); // use the URLClassLoader if (useSystem) { try { addURL(f.toURL()); if (verbose) System.out.println("RJavaClassLoader: added '" + cp + "' to the URL class path loader"); // return; // we need to add it anyway so it appears in .jclassPath() } catch (Exception ufe) { } } UnixFile g = null; if (f.isFile() && (f.getName().endsWith(".jar") || f.getName().endsWith(".JAR"))) { g = new UnixJarFile(cp); if (verbose) System.out.println( "RJavaClassLoader: adding Java archive file '" + cp + "' to the internal class path"); } else if (f.isDirectory()) { g = new UnixDirectory(cp); if (verbose) System.out.println( "RJavaClassLoader: adding class directory '" + cp + "' to the internal class path"); } else if (verbose) System.err.println( f.exists() ? ("WARNING: the path '" + cp + "' is neither a directory nor a .jar file, it will NOT be added to the internal class path!") : ("WARNING: the path '" + cp + "' does NOT exist, it will NOT be added to the internal class path!")); if (g != null && !classPath.contains(g)) { // this is the real meat - add it to our internal list classPath.add(g); // this is just cosmetics - it doesn't really have any meaning System.setProperty( "java.class.path", System.getProperty("java.class.path") + File.pathSeparator + g.getPath()); } }
public String getTimeEstimated() { if (currSize == 0) return "n/a"; long time = System.currentTimeMillis() - starttime; time = totalSize * time / currSize; time /= 1000l; if (time - 60l >= 0) { if (time % 60 >= 10) return time / 60 + ":" + (time % 60) + "m"; else return time / 60 + ":0" + (time % 60) + "m"; } else return time < 10 ? "0" + time + "s" : time + "s"; }
private void checkAndLaunchUpdate() { Log.i(LOG_FILE_NAME, "Checking for an update"); int statusCode = 8; // UNEXPECTED_ERROR File baseUpdateDir = null; if (Build.VERSION.SDK_INT >= 8) baseUpdateDir = getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS); else baseUpdateDir = new File(Environment.getExternalStorageDirectory().getPath(), "download"); File updateDir = new File(new File(baseUpdateDir, "updates"), "0"); File updateFile = new File(updateDir, "update.apk"); File statusFile = new File(updateDir, "update.status"); if (!statusFile.exists() || !readUpdateStatus(statusFile).equals("pending")) return; if (!updateFile.exists()) return; Log.i(LOG_FILE_NAME, "Update is available!"); // Launch APK File updateFileToRun = new File(updateDir, getPackageName() + "-update.apk"); try { if (updateFile.renameTo(updateFileToRun)) { String amCmd = "/system/bin/am start -a android.intent.action.VIEW " + "-n com.android.packageinstaller/.PackageInstallerActivity -d file://" + updateFileToRun.getPath(); Log.i(LOG_FILE_NAME, amCmd); Runtime.getRuntime().exec(amCmd); statusCode = 0; // OK } else { Log.i(LOG_FILE_NAME, "Cannot rename the update file!"); statusCode = 7; // WRITE_ERROR } } catch (Exception e) { Log.i(LOG_FILE_NAME, "error launching installer to update", e); } // Update the status file String status = statusCode == 0 ? "succeeded\n" : "failed: " + statusCode + "\n"; OutputStream outStream; try { byte[] buf = status.getBytes("UTF-8"); outStream = new FileOutputStream(statusFile); outStream.write(buf, 0, buf.length); outStream.close(); } catch (Exception e) { Log.i(LOG_FILE_NAME, "error writing status file", e); } if (statusCode == 0) System.exit(0); }
public void addEnvToIntent(Intent intent) { Map<String, String> envMap = System.getenv(); Set<Map.Entry<String, String>> envSet = envMap.entrySet(); Iterator<Map.Entry<String, String>> envIter = envSet.iterator(); int c = 0; while (envIter.hasNext()) { Map.Entry<String, String> entry = envIter.next(); intent.putExtra("env" + c, entry.getKey() + "=" + entry.getValue()); c++; } }
public static String getSystemName() { String name = System.getProperty("os.name"); // if(name.indexOf("Solaris") >= 0) return "solaris"; -- Deprecated in 1.6.2+ if (name.indexOf("Linux") >= 0) return "linux"; if (name.indexOf("Mac") >= 0) return "osx"; if (name.indexOf("Windows") >= 0) return "windows"; return "commodore64"; // Default choice. // Most likely as the C64 was the best selling home computer in history. // ToDon't: Check the SID version for the zealots. }
private void addIndex(JarIndex index, ZipOutputStream zos) throws IOException { ZipEntry e = new ZipEntry(INDEX_NAME); e.setTime(System.currentTimeMillis()); if (flag0) { CRC32OutputStream os = new CRC32OutputStream(); index.write(os); os.updateEntry(e); } zos.putNextEntry(e); index.write(zos); zos.closeEntry(); }
public void writeIdToVertexMap(String filePath) { try { BufferedWriter bw = new BufferedWriter(new FileWriter(new File(filePath))); for (Entry<Integer, String> entry : nodes.entrySet()) { bw.write(entry.getKey() + " " + entry.getValue() + "\n"); } bw.close(); } catch (Exception ex) { ex.printStackTrace(); System.exit(-1); } }
public Packet56MapChunks(List p_i3324_1_) { int i = p_i3324_1_.size(); field_73589_c = new int[i]; field_73586_d = new int[i]; field_73590_a = new int[i]; field_73588_b = new int[i]; field_73584_f = new byte[i][]; int j = 0; for (int k = 0; k < i; k++) { Chunk chunk = (Chunk) p_i3324_1_.get(k); Packet51MapChunkData packet51mapchunkdata = Packet51MapChunk.func_73594_a(chunk, true, 65535); if (field_73591_h.length < j + packet51mapchunkdata.field_74582_a.length) { byte abyte0[] = new byte[j + packet51mapchunkdata.field_74582_a.length]; System.arraycopy(field_73591_h, 0, abyte0, 0, field_73591_h.length); field_73591_h = abyte0; } System.arraycopy( packet51mapchunkdata.field_74582_a, 0, field_73591_h, j, packet51mapchunkdata.field_74582_a.length); j += packet51mapchunkdata.field_74582_a.length; field_73589_c[k] = chunk.field_76635_g; field_73586_d[k] = chunk.field_76647_h; field_73590_a[k] = packet51mapchunkdata.field_74580_b; field_73588_b[k] = packet51mapchunkdata.field_74581_c; field_73584_f[k] = packet51mapchunkdata.field_74582_a; } Deflater deflater = new Deflater(-1); try { deflater.setInput(field_73591_h, 0, j); deflater.finish(); field_73587_e = new byte[j]; field_73585_g = deflater.deflate(field_73587_e); } finally { deflater.end(); } }
public String getClasspath() { final StringBuilder sb = new StringBuilder(); boolean firstPass = true; final Enumeration<File> componentEnum = this.pathComponents.elements(); while (componentEnum.hasMoreElements()) { if (!firstPass) { sb.append(System.getProperty("path.separator")); } else { firstPass = false; } sb.append(componentEnum.nextElement().getAbsolutePath()); } return sb.toString(); }
public static void main(String[] args) throws Exception { int iterations = 0; File zFile1 = new File(System.getProperty("test.src", "."), "pkware123456789012345.zip"); while (iterations < 2500) { ZipFile zipFile = new ZipFile(zFile1); List entries = Collections.list(zipFile.entries()); for (Iterator it = entries.iterator(); it.hasNext(); ) { ZipEntry zipEntry = (ZipEntry) it.next(); InputStream in = zipFile.getInputStream(zipEntry); in.close(); } iterations++; } }
private File getFrameworkDir() throws AndrolibException { File dir = new File( System.getProperty("user.home") + File.separatorChar + "apktool" + File.separatorChar + "framework"); if (!dir.exists()) { if (!dir.mkdirs()) { throw new AndrolibException("Can't create directory: " + dir); } } return dir; }
/** @throws Exception If failed. */ @SuppressWarnings({"TypeMayBeWeakened"}) public void testCorrectAntGarTask() throws Exception { String tmpDirName = GridTestProperties.getProperty("ant.gar.tmpdir"); String srcDirName = GridTestProperties.getProperty("ant.gar.srcdir"); String baseDirName = tmpDirName + File.separator + System.currentTimeMillis() + "_0"; String metaDirName = baseDirName + File.separator + "META-INF"; String garFileName = baseDirName + ".gar"; String garDescDirName = U.resolveIgnitePath(GridTestProperties.getProperty("ant.gar.descriptor.dir")) .getAbsolutePath() + File.separator + "ignite.xml"; // Make base and META-INF dir. boolean mkdir = new File(baseDirName).mkdirs(); assert mkdir; mkdir = new File(metaDirName).mkdirs(); assert mkdir; // Make Gar file U.copy(new File(garDescDirName), new File(metaDirName + File.separator + "ignite.xml"), true); // Copy files to basedir U.copy(new File(srcDirName), new File(baseDirName), true); IgniteDeploymentGarAntTask garTask = new IgniteDeploymentGarAntTask(); Project garProject = new Project(); garProject.setName("Gar test project"); garTask.setDestFile(new File(garFileName)); garTask.setBasedir(new File(baseDirName)); garTask.setProject(garProject); garTask.execute(); File garFile = new File(garFileName); assert garFile.exists(); boolean res = checkStructure(garFile, true); assert res; }
private void fixRSNAROOT(Element server) { if (programName.equals("ISN")) { Element ssl = getFirstNamedChild(server, "SSL"); if (ssl != null) { if (System.getProperty("os.name").contains("Windows")) { ssl.setAttribute( "keystore", ssl.getAttribute("keystore").replace("RSNA_HOME", "RSNA_ROOT")); ssl.setAttribute( "truststore", ssl.getAttribute("truststore").replace("RSNA_HOME", "RSNA_ROOT")); } else { ssl.setAttribute("keystore", "${RSNA_ROOT}/conf/keystore.jks"); ssl.setAttribute("truststore", "${RSNA_ROOT}/conf/truststore.jks"); } } } }
public PrivateReader(String file, String head, String foot) throws MalformedURLException, IOException { header = head; footer = foot; if (file.indexOf("://") < 0) { internal = new BufferedReader(new FileReader(file)); } else if (file.startsWith("https:")) { log.debug("trying ssl connection..."); System.setProperty("sslfactory", "org.postgresql.ssl.NonValidatingFactory"); HttpsURLConnection conn = (HttpsURLConnection) (new URL(file)).openConnection(); internal = new BufferedReader(new InputStreamReader(conn.getInputStream()), 200000); } else if (file.endsWith(".z") || file.endsWith(".gz")) { internal = new InputStreamReader( new GZIPInputStream((new URL(file)).openConnection().getInputStream())); } else internal = new InputStreamReader((new URL(file)).openConnection().getInputStream()); }