Beispiel #1
0
 /**
  * Prints the properties of this device manager and all of the devices found on the bus to the
  * specified print stream. Mainly useful for diagnostic purposes.
  *
  * @param stream the print stream where properties will be printed.
  * @return The print stream.
  */
 public PrintStream print(PrintStream stream) {
   if (!isOpen()) throw new OperationFailedException(MESSAGE_NOT_OPEN);
   if (deviceList.size() > 0) {
     stream.println("ACCES devices found:");
     for (USBDevice device : deviceList) device.print(stream);
   } else stream.println("No ACCES devices found");
   return stream;
 } // print()
 // --------------------------------------------------
 public void close() {
   try {
     is.close();
     os.close();
     socket.close();
     responseArea.appendText("***Connection closed" + "\n");
   } catch (IOException e) {
     responseArea.appendText("IO Exception" + "\n");
   }
 }
 // --------------------------------------------------
 public void send() {
   os.println(commandArea.getText());
 }
Beispiel #4
0
 /**
  * ** Encodes the specified DBRecordKyes into XML and writes it to ** a specified PrintStream
  * ** @param out The PrintStream ** @param dbrk The list of DBRecordKeys
  */
 public static void printXML(PrintStream out, DBRecordKey... dbrk) {
   if (out != null) {
     DBRecordKey.printXML(new PrintWriter(out), dbrk);
     out.flush();
   }
 }
Beispiel #5
0
  public static void main(String args[]) {
    // Printing arguments just to show them
    boolean debug = false;
    if (debug) {
      for (int i = 0; i < args.length; i++) {
        System.err.printf("arg[%d]: %s\n", i, args[i]);
      }
    }

    // Now the real program
    InputStream in = System.in;
    PrintStream out = System.out;
    PrintStream err = System.err;

    String usage =
        "Usage: "
            + OLEWrapper.class.getName()
            + " [file]\n"
            + "\tfile = input file to read, default is stdin";

    if (args.length > 1) {
      out.println("Error: more than 1 argument");
      out.println(usage);
      System.exit(1);
    } else if (args.length == 1) {
      try {
        in = new BufferedInputStream(new FileInputStream(args[0]));
      } catch (FileNotFoundException e) {
        err.println("file " + args[0] + "was not found.");
        System.exit(2);
      }
    }
    // Then do the work...

    SAXParserFactory factory = SAXParserFactory.newInstance();
    factory.setNamespaceAware(true);
    try {
      SAXParser saxParser = factory.newSAXParser();
      DefaultHandler handler = new OLEImportHandler(out, err);
      XMLReader reader = saxParser.getXMLReader();
      if (debug) {
        out.println("factory.isNamespaceAware()=" + factory.isNamespaceAware());
        out.println("saxParser.isNamespaceAware()=" + saxParser.isNamespaceAware());
        out.println(SaxNSURI + "=" + reader.getFeature(SaxNSURI));
        System.exit(0);
      }
      reader.setContentHandler(handler);
      // Register lexical handler for comment processing
      reader.setProperty(SaxLexHandlerURI, handler);
      reader.parse(new InputSource(in));
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (ParserConfigurationException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (SAXException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    System.exit(0);
  }
  public static void main(String argv[]) {
    try {
      BufferedReader buf1 = new BufferedReader(new FileReader("./index/pIndex"));
      FileOutputStream out = new FileOutputStream("finalindex");
      PrintStream p = new PrintStream(out);
      String nline1, nline2, term1, term2, term3, term, t1, t2;
      StringBuffer sbuff = new StringBuffer();
      StringBuffer sbuff1;
      long df, postings = 0, line = 0;
      String[] id;
      int flag = 0;
      while (true) {
        nline1 = buf1.readLine();
        // System.out.println(nline1);
        if (nline1 == null) break;
        line++;
        String[] words = nline1.split(" ");
        String search_word = words[0];
        char ch = search_word.charAt(0);
        // System.out.println("c"+ch);
        id = words[1].split(",");
        df = id.length;
        flag = 0;
        sbuff1 = new StringBuffer(); // System.out.println(df);
        if (df > 30000 && ((ch == 't') || ch == 'o' || ch == 'c')) {
          int count = 0;
          postings = 0;
          System.out.println("before df" + df + ";line" + line); // System.out.println("here\n");
          while (count < df) {
            String temp1 = id[count];
            String temp[] = temp1.split(":");
            int t = Integer.parseInt(temp[1]);
            // System.out.println("t:"+t);
            if (t != 1) {
              if (flag == 0) {
                // System.out.println("here\n");
                sbuff1.append(search_word);
                sbuff1.append(" ");
                sbuff1.append(temp1);
                flag = 1;
              } else {
                sbuff1.append(",");
                sbuff1.append(temp1);
                postings++;
              }
            }
            count++;
          }
          // System.out.println(sbuff1);
          System.out.println("postings size after:" + postings + ";line" + line);
          p.println(sbuff1.toString());
          p.flush();
        } else {

          p.println(nline1);
          p.flush();
        }
      }

    } catch (IOException E) {
    }
  }
Beispiel #7
0
 protected void warning(String s) {
   if (warnings != null) {
     warnings.println(s);
   }
 }