public static void showSession(HttpServletRequest req, PrintStream out) { // res.setContentType("text/html"); // Get the current session object, create one if necessary HttpSession session = req.getSession(); out.println("Session id: " + session.getId()); out.println(" session.isNew(): " + session.isNew()); out.println(" session.getMaxInactiveInterval(): " + session.getMaxInactiveInterval() + " secs"); out.println( " session.getCreationTime(): " + session.getCreationTime() + " (" + new Date(session.getCreationTime()) + ")"); out.println( " session.getLastAccessedTime(): " + session.getLastAccessedTime() + " (" + new Date(session.getLastAccessedTime()) + ")"); out.println(" req.isRequestedSessionIdFromCookie: " + req.isRequestedSessionIdFromCookie()); out.println(" req.isRequestedSessionIdFromURL: " + req.isRequestedSessionIdFromURL()); out.println(" req.isRequestedSessionIdValid: " + req.isRequestedSessionIdValid()); out.println("Saved session Attributes:"); Enumeration atts = session.getAttributeNames(); while (atts.hasMoreElements()) { String name = (String) atts.nextElement(); out.println(" " + name + ": " + session.getAttribute(name) + "<BR>"); } }
private static void showThreads(PrintStream pw, ThreadGroup g, Thread current) { int nthreads = g.activeCount(); pw.println("\nThread Group = " + g.getName() + " activeCount= " + nthreads); Thread[] tarray = new Thread[nthreads]; int n = g.enumerate(tarray, false); for (int i = 0; i < n; i++) { Thread thread = tarray[i]; ClassLoader loader = thread.getContextClassLoader(); String loaderName = (loader == null) ? "Default" : loader.getClass().getName(); Thread.State state = thread.getState(); long id = thread.getId(); pw.print(" " + id + " " + thread.getName() + " " + state + " " + loaderName); if (thread == current) pw.println(" **** CURRENT ***"); else pw.println(); } int ngroups = g.activeGroupCount(); ThreadGroup[] garray = new ThreadGroup[ngroups]; int ng = g.enumerate(garray, false); for (int i = 0; i < ng; i++) { ThreadGroup nested = garray[i]; showThreads(pw, nested, current); } }
private void saveSqlScript(String fileName, String[] sql) throws FileNotFoundException { FileOutputStream fileOutputStream = new FileOutputStream(fileName); PrintStream printStream = new PrintStream(fileOutputStream); for (int i = 0; i < sql.length; i++) { printStream.println(sql[i] + getSqlDelimiter()); } }
static void printFooter(PrintStream file) { file.println(); file.println("#ifdef HAVE_JIKES_NAMESPACE"); file.println("} // Close namespace Jikes block"); file.println("#endif"); file.println(); }
public static void viewTagInfo(String inurl, String tag) throws Exception { // pr = new PrintStream(new FileOutputStream("/semplest/lluis/keywordExp/urldata.txt")); pr = System.out; long start = System.currentTimeMillis(); pr.println(inurl + "****************************************************************"); printList(cleanUrlText(TextUtils.HTMLText(inurl, tag))); String urls = TextUtils.HTMLLinkString(inurl, inurl); String[] url = urls.split("\\s+"); Set<String> urlMap = new HashSet<String>(url.length); urlMap.add(inurl); for (String ur : url) { if (!urlMap.contains(ur)) { pr.println(ur + "***************************************************************"); try { printList(cleanUrlText(TextUtils.HTMLText(ur, tag))); } catch (Exception e) { System.out.println("Error with url :" + ur); e.printStackTrace(); logger.error("Problem", e); } urlMap.add(ur); } } pr.println("Time elapsed" + (start - System.currentTimeMillis())); }
public static void println(double[] p, PrintStream ps) { for (int i = 0; i < p.length; i++) { ps.print(i > 0 ? " " : ""); ps.print(String.format("%.2f", p[i])); } ps.println(); }
protected int unknownArgument(String[] args, String arg, int argNum) { if (arg == "-t") { arg = args[++argNum]; if (arg.equalsIgnoreCase("parse")) setTraceParse(true); else if (arg.equalsIgnoreCase("gen")) setTraceGen(true); else if (arg.equalsIgnoreCase("dot")) setTraceDot(true); else { if (!arg.equalsIgnoreCase("all")) --argNum; // unknown value, trace all, and rethink that option setTraceParse(true); setTraceGen(true); setTraceMisc(true); setTraceDot(true); } } else if (arg == "-version") { messageOut.println("schema2beans - " + Version.getVersion()); System.exit(0); } else if (arg == "-xmlschema") setSchemaTypeNum(XML_SCHEMA); else if (arg == "-dtd") setSchemaTypeNum(DTD); else if (arg == "-premium") buyPremium(); else if (arg == "-strict") useStrict(); else if (arg == "-basebean") { setOutputType(OUTPUT_TRADITIONAL_BASEBEAN); } else if (arg == "-javabeans") setOutputType(OUTPUT_JAVABEANS); else if (arg == "-commoninterface") setGenerateCommonInterface(COMMON_BEAN); else if (arg == "-nocommoninterface") setGenerateCommonInterface(null); else { messageOut.println("Unknown argument: " + arg); messageOut.println("Use -help."); System.exit(1); } return argNum; }
public static void main(String[] args) { String tokensFile = args[0]; String progFile = args[1]; String tempFile = "CAMLE_TEMP.txt"; List<String> tokenName = new ArrayList<String>(); List<Integer> tokenType = new ArrayList<Integer>(); List<String> nameOf = new ArrayList<String>(); String line; boolean skipping = false; try { int nTokens = readTokensFile(tokensFile, tokenName, tokenType, nameOf); BufferedReader in = new BufferedReader(new FileReader(progFile)); PrintStream o = new PrintStream(new FileOutputStream(tempFile)); while ((line = in.readLine()) != null) { if (line.equals("// CAMLE TOKENS END")) { skipping = false; } if (!skipping) { o.println(line); } if (line.equals("// CAMLE TOKENS BEGIN")) { skipping = true; writeTokensCode(o, nTokens, tokenName, tokenType, nameOf); } } in.close(); o.close(); new File(tempFile).renameTo(new File(progFile)); } catch (Exception e) { System.out.println(e.toString()); System.exit(1); } }
public void init() { try { url = new URL(urlStr); // 创建一个代理服务器对象 proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyAddress, proxyPort)); // 使用指定的代理服务器打开连接 conn = url.openConnection(proxy); // 设置超时时长。 conn.setConnectTimeout(5000); scan = new Scanner(conn.getInputStream()); // 初始化输出流 ps = new PrintStream("Index.htm"); while (scan.hasNextLine()) { String line = scan.nextLine(); // 在控制台输出网页资源内容 System.out.println(line); // 将网页资源内容输出到指定输出流 ps.println(line); } } catch (MalformedURLException ex) { System.out.println(urlStr + "不是有效的网站地址!"); } catch (IOException ex) { ex.printStackTrace(); } // 关闭资源 finally { if (ps != null) { ps.close(); } } }
public void run() { if (clientSocket == null) { return; } PrintStream out = null; Utilities.printMsg("creating output stream"); try { out = new PrintStream(clientSocket.getOutputStream()); } catch (IOException e) { System.err.println("Error binding output to socket, " + e); System.exit(1); } Utilities.printMsg("writing current date"); Date d = new Date(); out.println(d); try { out.close(); clientSocket.close(); } catch (IOException e) { } }
/** * Determines if the given configuration is currently running. If any of the configurations are * currently stuck in the queue, it is logged. * * @param execution Contains information about the general build, including the listener used to * log queue blockage. * @param configuration The configuration being checked to see if it's running. * @param mutableWhyMap Mutable map used to track the reasons a configuration is stuck in the * queue. This prevents duplicate reasons from flooding the logs. * @return True if the build represented by the given configuration is currently running or stuck * in the queue. False if the build has finished running. */ private boolean isBuilding( MatrixBuild.MatrixBuildExecution execution, MatrixConfiguration configuration, Map<String, String> mutableWhyMap) { MatrixRun build = configuration.getBuildByNumber(execution.getBuild().getNumber()); if (build != null) { return build.isBuilding(); } Queue.Item queueItem = configuration.getQueueItem(); if (queueItem != null) { String why = queueItem.getWhy(); String key = queueItem.task.getFullDisplayName() + " " + queueItem.id; String oldWhy = mutableWhyMap.get(key); if (why == null) { mutableWhyMap.remove(key); } if (why != null && !why.equals(oldWhy)) { mutableWhyMap.put(key, why); BuildListener listener = execution.getListener(); PrintStream logger = listener.getLogger(); logger.print( "Configuration " + ModelHyperlinkNote.encodeTo(configuration) + " is still in the queue: "); queueItem.getCauseOfBlockage().print(listener); // this is still shown on the same line } } return true; }
private void sendProcessingError(Throwable t, ServletResponse response) { String stackTrace = getStackTrace(t); if (stackTrace != null && !stackTrace.equals("")) { try { response.setContentType("text/html"); PrintStream ps = new PrintStream(response.getOutputStream()); PrintWriter pw = new PrintWriter(ps); pw.print("<html>\n<head>\n</head>\n<body>\n"); // NOI18N // PENDING! Localize this for next official release pw.print("<h1>The resource did not process correctly</h1>\n<pre>\n"); pw.print(stackTrace); pw.print("</pre></body>\n</html>"); // NOI18N pw.close(); ps.close(); response.getOutputStream().close(); ; } catch (Exception ex) { } } else { try { PrintStream ps = new PrintStream(response.getOutputStream()); t.printStackTrace(ps); ps.close(); response.getOutputStream().close(); ; } catch (Exception ex) { } } }
public static void xinac() { out.println("xinac instruction"); // XINAC1 increment the value in AC by 1, setting/resetting flags // as appropriate if ((AC < 0) && (AC + 1 >= 0)) { flag[1] = true; } else { flag[1] = false; } if (AC > 0 && (short) (AC + 1) < 0) { flag[2] = true; } else { flag[2] = false; } AC++; // set other flags if (AC == 0) { flag[0] = true; } else { flag[0] = false; } if (AC < 0) { flag[3] = true; } else { flag[3] = false; } out.print("xinac1 AC = " + AC); printzcvn(); }
public static void xlsl() { out.println("xlsl instruction"); // XLSL1 shifts AC left one bit, sets/resets the flags // if AC is negative, carry bit will be true if ((short) AC < 0) { flag[1] = true; } else { flag[1] = false; } // setting overflow flag // if it changes sign, overflow if ((short) (0xFFFF & AC) > 0 && (short) ((0xFFFF & AC) << 1) < 0) { flag[2] = true; } else if ((short) (0xFFFF & AC) < 0 && (short) ((0xFFFF & AC) << 1) > 0) { flag[2] = true; } else { flag[2] = false; } AC += -(0xFFFF & AC) + (0xFFFF & AC << 1); out.println(0xFFFF & AC); // set the flags setFlagsXRotS(); out.print("xlsl1 AC = " + AC); printzcvn(); }
/** * There are two things we need to check * * <ul> * <li>files created or modified since last build time, we only need to check the source folder * <li>file deleted since last build time, we have to compare source and destination folder * </ul> */ @Override public boolean pollChanges( AbstractProject project, Launcher launcher, FilePath workspace, TaskListener listener) throws IOException, InterruptedException { long start = System.currentTimeMillis(); PrintStream log = launcher.getListener().getLogger(); log.println("FSSCM.pollChange: " + path); AllowDeleteList allowDeleteList = new AllowDeleteList(project.getRootDir()); // we will only delete a file if it is listed in the allowDeleteList // ie. we will only delete a file if it is copied by us if (allowDeleteList.fileExists()) { allowDeleteList.load(); } else { // watch list save file doesn't exist // we will assuem all existing files are under watch // ie. everything can be deleted Set<String> existingFiles = workspace.act(new RemoteListDir()); allowDeleteList.setList(existingFiles); } RemoteFolderDiff.PollChange callable = new RemoteFolderDiff.PollChange(); setupRemoteFolderDiff(callable, project, allowDeleteList.getList()); boolean changed = workspace.act(callable); String str = callable.getLog(); if (str.length() > 0) log.println(str); log.println("FSSCM.pollChange return " + changed); log.println( "FSSCM.poolChange completed in " + formatDurration(System.currentTimeMillis() - start)); return changed; }
public void WriteHeader(){ out.println("\t\t"+Parser.StartingTag("ValidichroHeader")); out.println("\t\t\t"+Parser.Tag("Date",experiment_date)); out.println("\t\t\t"+Parser.Tag("Generic",generic)); //... out.println("\t\t"+Parser.EndingTag("ValidichroHeader")); }
/** * ********************************************************************** Prints the iniFile. * * @param ps The <code>PrintStream</code> to which to print. */ public void printProps(PrintStream ps) { Enumeration se = getSectionList(); if (se == null) { ps.println(errMsg); } else { while (se.hasMoreElements()) { String sname = (String) se.nextElement(); setSection(sname); ps.println("[" + sname + "]"); Enumeration pe = getPropList(sname); while (pe.hasMoreElements()) { String pair[] = (String[]) pe.nextElement(); String prop = pair[0]; String valu = getProperty(prop); ps.println(" \"" + prop + "\" = \"" + valu + "\""); } } } }
/** Try the given mail server, writing output to the given PrintStream */ public static void process(String suspect_relay, PrintStream pw) { pw.println("processs: trying: " + suspect_relay); try { // Redirect all output from mail API to the given stream. System.setOut(pw); System.setErr(pw); Sender2 sm = new Sender2(suspect_relay); sm.addRecipient("*****@*****.**"); sm.setFrom(MY_TARGET); sm.setSubject("Testing for open mail relay, see " + RSS_SITE); sm.setBody( "This mail is an attempt to confirm that site " + suspect_relay + "\n" + "is in fact an open mail relay site.\n" + "For more information on the problem of open mail relays,\n" + "please visit site " + RSS_SITE + "\n" + "Please join the fight against spam by closing all open mail relays!\n" + "If this open relay has been closed, please accept our thanks.\n"); sm.sendFile(); } catch (MessagingException e) { pw.println(e); } catch (Exception e) { pw.println(e); } }
// rl // rl rotates AC left one bit, sets/resets all flags public static void rl() { out.println("rl instruction"); // RL1 rotates AC left one bit, sets/resets the flags // if AC is negative, carry bit will be true if ((byte) AC < 0) { flag[1] = true; } else { flag[1] = false; } // setting overflow flag // if it changes sign, overflow if ((byte) (0xFF & AC) > 0 && (byte) ((0xFF & AC) << 1) < 0) { flag[2] = true; } else if ((byte) (0xFF & AC) < 0 && (byte) ((0xFF & AC) << 1) > 0) { flag[2] = true; } else { flag[2] = false; } AC += -(0xFF & AC) + (0xFF & AC << 1); // if there is a carried bit, set the LSB to 1 if (flag[1]) { AC++; } // set the remaining flags setFlagsRotS(); out.print("rl1 AC = " + (byte) (0xFF & AC)); printzcvn(); }
/** * Prints the given map with nice line breaks. * * @param out the stream to print to * @param key the key that maps to the map in some other map * @param map the map to print */ public static synchronized void debugPrint(PrintStream out, Object key, Map map) { debugPrintIndent(out); out.println(key + " = "); debugPrintIndent(out); out.println("{"); ++debugIndent; for (Iterator iter = map.entrySet().iterator(); iter.hasNext(); ) { Map.Entry entry = (Map.Entry) iter.next(); String childKey = (String) entry.getKey(); Object childValue = entry.getValue(); if (childValue instanceof Map) { verbosePrint(out, childKey, (Map) childValue); } else { debugPrintIndent(out); String typeName = (childValue != null) ? childValue.getClass().getName() : null; out.println(childKey + " = " + childValue + " class: " + typeName); } } --debugIndent; debugPrintIndent(out); out.println("}"); }
// inac // inac increments the accumulator public static void inac() { out.println("inac instruction"); // INAC1 increment the value in AC by 1, setting/resetting flags // as appropriate if (((byte) (AC) < 0) && ((byte) (AC + 1) >= 0)) { flag[1] = true; } else { flag[1] = false; } if ((byte) (AC) == 127) { flag[2] = true; } else { flag[2] = false; } if ((byte) (AC) == -1) { AC -= 0xFF & AC; } else { AC++; } // set other flags if ((byte) AC == 0) { flag[0] = true; } else { flag[0] = false; } if ((byte) AC < 0) { flag[3] = true; } else { flag[3] = false; } out.print("inac1 AC = " + (byte) (0xFF & AC)); printzcvn(); }
// jumper // jumper carries out the jump instruction for the conditional jumps public static void jumper(String op) { // JUMP1 read the high order half of the address into DR DR = readMemory(AR); PC++; AR++; out.println( op + "1 AR = " + ((int) 0xFFFF & AR) + " PC = " + ((int) 0xFFFF & PC) + " DR = " + ((int) 0xFF & DR)); // JUMP2 save the contents of DR TR = DR; DR = readMemory(AR); PC++; out.println( op + "2 AR = " + ((int) 0xFFFF & AR) + " PC = " + ((int) 0xFFFF & PC) + " DR = " + ((int) 0xFF & DR) + " TR = " + ((int) 0xFF & TR)); // JUMP3 form the address from TR and DR and place it in PC PC = (short) (((0xFF & TR) * 256) + (0xFF & DR)); out.println(op + "3 PC = " + ((int) 0xFFFF & AR)); }
public static void xlsr() { out.println("xlsr instruction"); // LSR1 shifts AC right one bit, sets/resets all flags if ((short) AC < 0) { if (((short) AC * -1) % 2 == 1) { flag[1] = true; } else { flag[1] = false; } } else if ((short) AC % 2 == 1) { flag[1] = true; } else { flag[1] = false; } int conv; conv = AC & 0xFFFF; conv >>>= 1; // setting overflow flag // if it changes sign, overflow if ((short) (0xFFFF & AC) > 0 && (short) conv < 0) { flag[2] = true; } else if ((short) (0xFFFF & AC) < 0 && (short) conv > 0) { flag[2] = true; } else { flag[2] = false; } AC += -(0xFFFF & AC) + conv; // set the flags setFlagsXRotS(); out.print("xlsr1 AC = " + AC); printzcvn(); }
@Override public boolean checkout( AbstractBuild build, Launcher launcher, FilePath workspace, BuildListener listener, File changelogFile) throws IOException, InterruptedException { long start = System.currentTimeMillis(); PrintStream log = launcher.getListener().getLogger(); log.println("FSSCM.checkout " + path + " to " + workspace); Boolean b = Boolean.TRUE; AllowDeleteList allowDeleteList = new AllowDeleteList(build.getProject().getRootDir()); if (clearWorkspace) { log.println("FSSCM.clearWorkspace..."); workspace.deleteRecursive(); } // we will only delete a file if it is listed in the allowDeleteList // ie. we will only delete a file if it is copied by us if (allowDeleteList.fileExists()) { allowDeleteList.load(); } else { // watch list save file doesn't exist // we will assuem all existing files are under watch // ie. everything can be deleted Set<String> existingFiles = workspace.act(new RemoteListDir()); allowDeleteList.setList(existingFiles); } RemoteFolderDiff.CheckOut callable = new RemoteFolderDiff.CheckOut(); setupRemoteFolderDiff(callable, build.getProject(), allowDeleteList.getList()); List<FolderDiff.Entry> list = workspace.act(callable); // maintain the watch list for (FolderDiff.Entry entry : list) { if (FolderDiff.Entry.Type.DELETED.equals(entry.getType())) { allowDeleteList.remove(entry.getFilename()); } else { // added or modified allowDeleteList.add(entry.getFilename()); } } allowDeleteList.save(); // raw log String str = callable.getLog(); if (str.length() > 0) log.println(str); ChangelogSet.XMLSerializer handler = new ChangelogSet.XMLSerializer(); ChangelogSet changeLogSet = new ChangelogSet(build, list); handler.save(changeLogSet, changelogFile); log.println("FSSCM.check completed in " + formatDurration(System.currentTimeMillis() - start)); return b; }
public static void writeLinesToFile(File file, List<?> lines) throws Exception { PrintStream output = new PrintStream(new FileOutputStream(file)); for (Iterator<?> iterator = lines.iterator(); iterator.hasNext(); ) { String line = (String) iterator.next(); output.println(line); } output.close(); }
/** * Generates XML description of the OD.<br> * If the print stream is specified, then XML buffer is written to the stream. * * @param out print stream. * @throws IOException */ public void xmlDump(PrintStream out) throws IOException { if (out == null) out = System.out; out.print("<od begin=\"" + origin.getId() + "\" end=\"" + destination.getId() + "\">\n"); out.print("<PathList>\n"); for (int i = 0; i < pathList.size(); i++) pathList.get(i).xmlDump(out); out.print("</PathList>\n</od>\n"); return; }
private static void outputProbes(Iterator<ProbeLine> lines, File f) throws IOException { PrintStream ps = new PrintStream(new FileOutputStream(f)); while (lines.hasNext()) { ProbeLine line = lines.next(); ps.println(line.toString()); } ps.close(); }
public void WriteExported(){ out.println(Parser.getFileHeader()); out.println("\t"+Parser.StartingTag("ValidichroData")); WriteHeader(); WriteBody(); WriteUnparsed(); out.println("\t"+Parser.EndingTag("ValidichroData")); }
public void Print(PrintStream outfile) { outfile.printf(weocode + " " + countryname + " " + currency + " " + scale + " "); for (Double b : gdplist) outfile.printf(b + " "); outfile.println("Average GDP = " + average + " Standard Deviation = " + stdev); }
// add // add adds the value in R with AC, and places the value in AC public static void add() { out.println("add instruction"); // ADD1 adds R into AC, and sets the flags as appropriate add1(); out.print("add1 AC = " + (byte) (0xFF & AC) + " R = " + (byte) (0xFF & R)); printzcvn(); }