Пример #1
1
 static void initWords(int size, Object[] key, Object[] abs) {
   String fileName = "testwords.txt";
   int ki = 0;
   int ai = 0;
   try {
     FileInputStream fr = new FileInputStream(fileName);
     BufferedInputStream in = new BufferedInputStream(fr);
     while (ki < size || ai < size) {
       StringBuffer sb = new StringBuffer();
       for (; ; ) {
         int c = in.read();
         if (c < 0) {
           if (ki < size) randomWords(key, ki, size);
           if (ai < size) randomWords(abs, ai, size);
           in.close();
           return;
         }
         if (c == '\n') {
           String s = sb.toString();
           if (ki < size) key[ki++] = s;
           else abs[ai++] = s;
           break;
         }
         sb.append((char) c);
       }
     }
     in.close();
   } catch (IOException ex) {
     System.out.println("Can't read words file:" + ex);
     throw new Error(ex);
   }
 }
Пример #2
0
  protected String getDropSQL(DatabaseObjectType type, String name) {
    SQLObject foundDropQuery = null;
    String sqlStatement = "DROP " + type.toString() + " " + name;

    for (SQLObject dropQuery : catalogStore.getDropStatements()) {
      if (type == dropQuery.getType()) {
        foundDropQuery = dropQuery;
        break;
      }
    }

    if (foundDropQuery != null
        && foundDropQuery.getSql() != null
        && !foundDropQuery.getSql().isEmpty()) {
      String dropStatement = foundDropQuery.getSql();
      StringBuffer sqlBuffer = new StringBuffer(dropStatement.length() + name.length());
      int identifier = dropStatement.indexOf('?');

      sqlBuffer
          .append(dropStatement.substring(0, identifier))
          .append(name)
          .append(dropStatement.substring(identifier + 1));
      sqlStatement = sqlBuffer.toString();
    }

    return sqlStatement;
  }
  private Set<String> getListenerClassNames(final String xml, final String path)
      throws IOException, SAXException {

    final Digester digester = getDigester();
    digester.addObjectCreate(XmlConfiguration.listeners, ArrayList.class);
    digester.addObjectCreate(path, StringBuffer.class); // TODO rather than StringBuffer can
    digester.addCallMethod(path, "append", 0); // TODO this be a String?
    digester.addSetRoot(path, "add");

    final Set<String> classNames = new HashSet<String>();

    final StringReader includeReader = new StringReader(xml);
    Object o = digester.parse(includeReader);

    if (o == null) {

      // return empty Set
      return classNames;
    }

    Collection<StringBuffer> classNamesAsStringBuffers = (Collection<StringBuffer>) o;

    /** When the configuration contains no listener settings, return the empty Set */
    if (classNamesAsStringBuffers == null) {

      return classNames;
    }

    for (StringBuffer classNamesAsStringBuffer : classNamesAsStringBuffers) {

      classNames.add(classNamesAsStringBuffer.toString());
    }

    return classNames;
  }
Пример #4
0
 /**
  * ** Reads a line from the specified socket's input stream ** @param socket The socket to read a
  * line from ** @param maxLen The maximum length of of the line to read ** @param sb The string
  * buffer to use ** @throws IOException if an error occurs or the server has stopped
  */
 protected static String socketReadLine(Socket socket, int maxLen, StringBuffer sb)
     throws IOException {
   if (socket != null) {
     int dataLen = 0;
     StringBuffer data = (sb != null) ? sb : new StringBuffer();
     InputStream input = socket.getInputStream();
     while ((maxLen < 0) || (maxLen > dataLen)) {
       int ch = input.read();
       // Print.logInfo("ReadLine char: " + ch);
       if (ch < 0) {
         // this means that the server has stopped
         throw new IOException("End of input");
       } else if (ch == LineTerminatorChar) {
         // include line terminator in String
         data.append((char) ch);
         dataLen++;
         break;
       } else {
         // append character
         data.append((char) ch);
         dataLen++;
       }
     }
     return data.toString();
   } else {
     return null;
   }
 }
Пример #5
0
  /**
   * Returns a String representation of the <code>&lt;saml:Attribute&gt;</code> element.
   *
   * @param includeNS Determines whether or not the namespace qualifier is prepended to the Element
   *     when converted
   * @param declareNS Determines whether or not the namespace is declared within the Element.
   * @return A string containing the valid XML for this element
   */
  public String toString(boolean includeNS, boolean declareNS) {
    StringBuffer result = new StringBuffer(1000);
    String prefix = "";
    String uri = "";
    if (includeNS) {
      prefix = SAMLConstants.ASSERTION_PREFIX;
    }
    if (declareNS) {
      uri = SAMLConstants.assertionDeclareStr;
    }
    result
        .append("<")
        .append(prefix)
        .append("Attribute")
        .append(uri)
        .append(" AttributeName=\"")
        .append(_attributeName)
        .append("\" AttributeNamespace=\"")
        .append(_attributeNameSpace)
        .append("\">\n");

    Iterator iter = _attributeValue.iterator();
    while (iter.hasNext()) {
      result.append(XMLUtils.printAttributeValue((Element) iter.next(), prefix)).append("\n");
    }
    result.append("</").append(prefix).append("Attribute>\n");
    return result.toString();
  }
Пример #6
0
  public boolean shutdown(int port, boolean ssl) {
    try {
      String protocol = "http" + (ssl ? "s" : "");
      URL url = new URL(protocol, "127.0.0.1", port, "shutdown");
      HttpURLConnection conn = (HttpURLConnection) url.openConnection();
      conn.setRequestMethod("GET");
      conn.setRequestProperty("servicemanager", "shutdown");
      conn.connect();

      StringBuffer sb = new StringBuffer();
      BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
      int n;
      char[] cbuf = new char[1024];
      while ((n = br.read(cbuf, 0, cbuf.length)) != -1) sb.append(cbuf, 0, n);
      br.close();
      String message = sb.toString().replace("<br>", "\n");
      if (message.contains("Goodbye")) {
        cp.appendln("Shutting down the server:");
        String[] lines = message.split("\n");
        for (String line : lines) {
          cp.append("...");
          cp.appendln(line);
        }
        return true;
      }
    } catch (Exception ex) {
    }
    cp.appendln("Unable to shutdown CTP");
    return false;
  }
  private void parse(String filename) throws Exception {
    BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(filename)));
    StringBuffer sb = new StringBuffer();

    int j;
    while ((j = br.read()) != -1) {
      char next = (char) j;

      if (next >= 'A' && next <= 'z') {
        sb.append(next);
      }

      if (sb.length() == 4) {
        String qGram = sb.toString().toUpperCase();
        sb = new StringBuffer();

        int frequency = 0;

        if (map.containsKey(qGram)) {
          frequency = map.get(qGram);
        }

        frequency++;
        map.put(qGram, frequency);
      }
    }
    br.close();
  }
Пример #8
0
 public String toString() {
   StringBuffer buf = new StringBuffer();
   for (int i = 0; i < m_Size; i++) {
     buf.append(getBit(i) ? '1' : '0');
   }
   return buf.toString();
 }
Пример #9
0
 /** Converts a normal string to a html conform string */
 public static String conv2Html(String st) {
   StringBuffer buf = new StringBuffer();
   for (int i = 0; i < st.length(); i++) {
     buf.append(conv2Html(st.charAt(i)));
   }
   return buf.toString();
 }
Пример #10
0
 public static String text(NodeList nodeList) {
   StringBuffer sb = new StringBuffer();
   for (int i = 0; i < nodeList.getLength(); i++) {
     sb.append(text(nodeList.item(i)));
   }
   return sb.toString();
 }
Пример #11
0
  public static void LCS(String str, String str2) {
    int len = str.length();
    int len2 = str2.length();
    int[][] storage = new int[len + 1][len2 + 1];
    for (int i = 0; i <= len; i++) {
      for (int j = 0; j <= len2; j++) {
        if (i == 0 || j == 0) {
          storage[i][j] = 0;
        } else if (str.charAt(i - 1) == str2.charAt(j - 1)) {
          storage[i][j] = 1 + storage[i - 1][j - 1];
        } else {
          storage[i][j] = Math.max(storage[i - 1][j], storage[i][j - 1]);
        }
      }
    }

    int i = len;
    int j = len2;
    StringBuffer sb = new StringBuffer();
    while (storage[i][j] > 0) {
      if (str.charAt(i - 1) == str2.charAt(j - 1)) {
        sb.insert(0, str.charAt(i - 1));
        i--;
        j--;
      } else if (storage[i - 1][j] > storage[i][j - 1]) {
        i--;
      } else {
        j--;
      }
    }
    System.out.println(sb.toString());
  }
Пример #12
0
 private ClassLoaderStrategy getClassLoaderStrategy(String fullyQualifiedClassName)
     throws Exception {
   try {
     // Get just the package name
     StringBuffer sb = new StringBuffer(fullyQualifiedClassName);
     sb.delete(sb.lastIndexOf("."), sb.length());
     currentPackage = sb.toString();
     // Retrieve the Java classpath from the system properties
     String cp = System.getProperty("java.class.path");
     String sepChar = System.getProperty("path.separator");
     String[] paths = StringUtils.pieceList(cp, sepChar.charAt(0));
     ClassLoaderStrategy cl =
         ClassLoaderUtil.getClassLoader(ClassLoaderUtil.FILE_SYSTEM_CLASS_LOADER, new String[] {});
     // Iterate through paths until class with the specified name is found
     String classpath = StringUtils.replaceChar(currentPackage, '.', File.separatorChar);
     for (int i = 0; i < paths.length; i++) {
       Class[] classes = cl.getClasses(paths[i] + File.separatorChar + classpath, currentPackage);
       for (int j = 0; j < classes.length; j++) {
         if (classes[j].getName().equals(fullyQualifiedClassName)) {
           return ClassLoaderUtil.getClassLoader(
               ClassLoaderUtil.FILE_SYSTEM_CLASS_LOADER, new String[] {paths[i]});
         }
       }
     }
     throw new Exception("Class could not be found.");
   } catch (Exception e) {
     System.err.println("Exception creating class loader strategy.");
     System.err.println(e.getMessage());
     throw e;
   }
 }
Пример #13
0
  /**
   * Return the number of characters that will be printed when the specified character is echoed to
   * the screen. Adapted from cat by Torbjorn Granlund, as repeated in stty by David MacKenzie.
   */
  StringBuffer getPrintableCharacters(char ch) {
    StringBuffer sbuff = new StringBuffer();

    if (ch >= 32) {
      if (ch < 127) {
        sbuff.append(ch);
      } else if (ch == 127) {
        sbuff.append('^');
        sbuff.append('?');
      } else {
        sbuff.append('M');
        sbuff.append('-');

        if (ch >= (128 + 32)) {
          if (ch < (128 + 127)) {
            sbuff.append((char) (ch - 128));
          } else {
            sbuff.append('^');
            sbuff.append('?');
          }
        } else {
          sbuff.append('^');
          sbuff.append((char) (ch - 128 + 64));
        }
      }
    } else {
      sbuff.append('^');
      sbuff.append((char) (ch + 64));
    }

    return sbuff;
  }
Пример #14
0
 /**
  * Starts a new column, possibly closing the current column if needed
  *
  * @param ret the output buffer to put LaTeX into
  * @param p the properties from the <code>&lt;td&gt;</code> tag
  */
 public void startCol(StringBuffer ret, Properties p) {
   endCol(ret);
   int span = hasNumProp("colspan", p);
   if (colcnt > 0) {
     ret.append(" & ");
   }
   String align = hasProp("align", p);
   if (align != null && span < 0) span = 1;
   if (span > 0) {
     ret.append("\\multicolumn{" + span + "}{");
     if (border && colcnt == 0) ret.append("|");
     String cc =
         ""
             + (char) ('a' + (colcnt / (26 * 26)))
             + (char) ((colcnt / 26) + 'a')
             + (char) ((colcnt % 26) + 'a');
     if (align != null) {
       String h = align.substring(0, 1);
       if ("rR".indexOf(h) >= 0) ret.append("r");
       else if ("lL".indexOf(h) >= 0) ret.append("p{\\tbl" + tc + "c" + cc + "w}");
       else if ("cC".indexOf(h) >= 0) ret.append("p{\\tbl" + tc + "c" + cc + "w}");
     } else ret.append("p{\\tbl" + tc + "c" + cc + "w}");
     if (border) ret.append("|");
     ret.append("}");
   }
   String wid = p.getProperty("texwidth");
   ret.append("{");
   if (wid != null) {
     ret.append("\\parbox{" + wid + "}{\\vskip 1ex ");
     parboxed = true;
   }
   colcnt++;
   colopen = true;
 }
 private String mkStr(char kar, int num) {
   StringBuffer sb = new StringBuffer(num);
   for (int ix = 0; ix < num; ix++) {
     sb.append(kar);
   }
   return sb.toString();
 }
 public String toString() {
   StringBuffer buffer = new StringBuffer("Queue:\n"); // $NON-NLS-1$
   for (int i = this.start; i <= this.end; i++) {
     buffer.append(this.names[i]).append('\n');
   }
   return buffer.toString();
 }
Пример #17
0
 // ----------------------------------------------------------------------
 // for "SrvTypeRqst"
 // get the list of service types for specified scope & naming authority
 // ----------------------------------------------------------------------
 public synchronized String getServiceTypeList(String na, String scope) {
   Vector typelist = new Vector(5);
   Iterator values = table.values().iterator();
   while (values.hasNext()) {
     Entry e = (Entry) values.next();
     if (!e.getDeleted()
         && // nor deleted
         scope.equalsIgnoreCase(e.getScope())
         && // match scope
         (na.equals("*")
             || // NA wildcard
             na.equalsIgnoreCase(e.getNA()))
         && // match NA
         !typelist.contains(e.getType())) {
       typelist.addElement(e.getType());
     }
   }
   StringBuffer tl = new StringBuffer();
   for (int i = 0; i < typelist.size(); i++) {
     String s = (String) typelist.elementAt(i);
     if (tl.length() > 0) tl.append(",");
     tl.append(s);
   }
   return tl.toString();
 }
  /** ** Reads/returns the specified CompileTime template file */
  private static String readTemplate(File tf, String pkgName) {

    /* read template data */
    byte templData[] = FileTools.readFile(tf);
    if (templData == null) {
      Print.errPrintln("\nUnable to read Input/Template file: " + tf);
      return null;
    } else if (templData.length == 0) {
      Print.errPrintln("\nInput/Template file is empty: " + tf);
      return null;
    }

    /* return template String */
    String templateText = StringTools.toStringValue(templData);
    if (!StringTools.isBlank(pkgName) && !StringTools.isBlank(templateText)) {
      String lines[] = StringTools.split(templateText, '\n', false);
      for (int i = 0; i < lines.length; i++) {
        if (lines[i].trim().startsWith(JAVA_PACKAGE_)) {
          lines[i] = CompiletimeVars.packageLine(pkgName);
          return StringTools.join(lines, '\n') + "\n";
        }
      }
      StringBuffer sb = new StringBuffer();
      sb.append(CompiletimeVars.packageLine(pkgName)).append("\n");
      sb.append(templateText);
      return sb.toString();
    } else {
      return templateText;
    }
  }
 private String addNewInteraction(String fingerprint, BiologicalInteraction interaction)
     throws SQLException {
   String sql =
       String.format(
           "INSERT IGNORE INTO interaction (fingerprint) VALUES (%s)",
           SqlUtil.toSqlVarchar(fingerprint));
   if (1 != DBUtil.update(sql)) {
     System.out.println("SQL update failed? " + sql);
   }
   String interaction_id = DBUtil.querySingle("SELECT LAST_INSERT_ID()");
   Iterator<BiologicalEntity> iter = interaction.getEntityIterator();
   StringBuffer sb =
       new StringBuffer(
           "INSERT IGNORE INTO interaction_pool (interaction_id, gene_id, entity_src_table, role) VALUES ");
   while (iter.hasNext()) {
     BiologicalEntity entity = iter.next();
     sb.append("(")
         .append(interaction_id)
         .append(", ")
         .append(SqlUtil.toSqlVarchar(entity.getId()))
         .append(", '")
         .append(srcTableLookup.get(entity.getId_src()))
         .append("', '")
         .append(entity.getRole())
         .append("')");
     if (iter.hasNext()) sb.append(", ");
   }
   if (DBUtil.update(sb.toString()) != interaction.getEnvolvedEntityCount()) {
     System.out.println("SQL update failed? " + sb);
   }
   return interaction_id;
 }
Пример #20
0
 /**
  * Returns the full URL of the request including the query string.
  *
  * <p>Used as a convenience method for logging purposes.
  *
  * @param request the request object.
  * @return the full URL of the request including the query string.
  */
 protected String getRequestURL(HttpServletRequest request) {
   StringBuffer sb = request.getRequestURL();
   if (request.getQueryString() != null) {
     sb.append("?").append(request.getQueryString());
   }
   return sb.toString();
 }
Пример #21
0
  /**
   * convert email address mapping<br>
   * <code>user-</code> will be replace by the email address of the user as stored in the user
   * repository <code>group-</code> will
   */
  public String convertEmailList(String mailTo) {
    StringBuffer ret = new StringBuffer();
    String[] list = mailTo.split(";");
    if (list == null) {
      return "";
    }
    for (int i = 0; i < list.length; i++) { // for each item
      String userName = list[i];
      if (i != 0) {
        ret.append("\n");
      }
      if (userName.startsWith(MailConstants.PREFIX_USER)) {
        userName = StringUtils.removeStart(userName, MailConstants.PREFIX_USER);
        if (log.isDebugEnabled()) {
          log.debug("username =" + userName);
        }
        ret.append(getUserMail(userName));
      } else if (userName.startsWith(MailConstants.PREFIX_GROUP)) {

      } else if (userName.startsWith(MailConstants.PREFIX_ROLE)) {

      } else {
        // none of the above, just add the mail to the list
        ret.append(userName);
      }
    }
    return ret.toString();
  }
Пример #22
0
  public void addDataSet(Color color, String legend, Data data[]) throws Exception {

    /* init */
    this._initChart();

    /* dataset color/legend/markers */
    String hexColor = ColorTools.toHexString(color, false);
    this.addDatasetColor(hexColor);
    this.addDatasetLegend(legend);
    this.addShapeMarker("d," + hexColor + "," + this.dataSetCount + ",-1,7,1");

    /* data */
    StringBuffer xv = new StringBuffer();
    StringBuffer yv = new StringBuffer();
    for (int i = 0; i < data.length; i++) {
      GetScaledExtendedEncodedValue(yv, data[i].getTempC(), this.minTempC, this.maxTempC);
      GetScaledExtendedEncodedValue(xv, data[i].getTimestamp(), this.minDateTS, this.maxDateTS);
    }
    if (StringTools.isBlank(this.chd)) {
      this.chd = "e:";
    } else {
      this.chd += ",";
    }
    this.chd += xv.toString() + "," + yv.toString();

    /* count data set */
    this.dataSetCount++;
  }
Пример #23
0
 /**
  * Adds <code>AttributeValue</code> to the Attribute.
  *
  * @param value A String representing <code>AttributeValue</code>.
  * @exception SAMLException
  */
 public void addAttributeValue(String value) throws SAMLException {
   if (value == null || value.length() == 0) {
     if (SAMLUtilsCommon.debug.messageEnabled()) {
       SAMLUtilsCommon.debug.message("addAttributeValue: Input is null");
     }
     throw new SAMLRequesterException(SAMLUtilsCommon.bundle.getString("nullInput"));
   }
   StringBuffer sb = new StringBuffer(300);
   sb.append("<")
       .append(SAMLConstants.ASSERTION_PREFIX)
       .append("AttributeValue")
       .append(SAMLConstants.assertionDeclareStr)
       .append(">")
       .append(value)
       .append("</")
       .append(SAMLConstants.ASSERTION_PREFIX)
       .append("AttributeValue>");
   try {
     Element ele =
         XMLUtils.toDOMDocument(sb.toString().trim(), SAMLUtilsCommon.debug).getDocumentElement();
     if (_attributeValue == null) {
       _attributeValue = new ArrayList();
     }
     if (!(_attributeValue.add(ele))) {
       if (SAMLUtilsCommon.debug.messageEnabled()) {
         SAMLUtilsCommon.debug.message(
             "Attribute: failed to " + "add to the attribute value list.");
       }
       throw new SAMLRequesterException(SAMLUtilsCommon.bundle.getString("addListError"));
     }
   } catch (Exception e) {
     SAMLUtilsCommon.debug.error("addAttributeValue error", e);
     throw new SAMLRequesterException("Exception in addAttributeValue" + e.getMessage());
   }
 }
Пример #24
0
 public static String randomHash(int length) {
   StringBuffer buffer = new StringBuffer();
   for (int i = 0; i < length; i++) {
     buffer.append(DIC[(int) (System.nanoTime() % 32)]);
   }
   return buffer.toString();
 }
Пример #25
0
 /**
  * @description: Decodes the supplied lzw encoded string
  * @method decode
  * @param {string} s
  * @param {function} callback
  */
 public static String decode(List<Integer> encoded) {
   // Build the dictionary.
   int dictSize = 256;
   Map<Integer, String> dictionary = new HashMap<Integer, String>();
   for (int i = 0; i < 256; i++) {
     dictionary.put(i, "" + (char) i);
   }
   String w = "" + (char) (int) encoded.remove(0);
   StringBuffer result = new StringBuffer(w);
   for (int k : encoded) {
     String entry;
     if (dictionary.containsKey(k)) {
       entry = dictionary.get(k);
     } else if (k == dictSize) {
       entry = w + w.charAt(0);
     } else {
       throw new IllegalArgumentException("Bad compressed k: " + k);
     }
     result.append(entry);
     // Add w+entry[0] to the dictionary.
     dictionary.put(dictSize++, w + entry.charAt(0));
     w = entry;
   }
   return result.toString();
 }
Пример #26
0
 /**
  * ************************************************************************ Lineas de Remesa
  *
  * @param whereClause where clause or null (starting with AND)
  * @return lines
  */
 public MRemesaLine[] getLines(String whereClause, String orderClause) {
   ArrayList list = new ArrayList();
   StringBuffer sql = new StringBuffer("SELECT * FROM C_RemesaLine WHERE C_Remesa_ID=? ");
   if (whereClause != null) sql.append(whereClause);
   if (orderClause != null) sql.append(" ").append(orderClause);
   PreparedStatement pstmt = null;
   try {
     pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
     pstmt.setInt(1, getC_Remesa_ID());
     ResultSet rs = pstmt.executeQuery();
     while (rs.next()) list.add(new MRemesaLine(getCtx(), rs));
     rs.close();
     pstmt.close();
     pstmt = null;
   } catch (Exception e) {
     log.saveError("getLines - " + sql, e);
   } finally {
     try {
       if (pstmt != null) pstmt.close();
     } catch (Exception e) {
     }
     pstmt = null;
   }
   //
   MRemesaLine[] lines = new MRemesaLine[list.size()];
   list.toArray(lines);
   return lines;
 } //	getLines
Пример #27
0
    public void run() {
      StringBuffer data = new StringBuffer();
      Print.logDebug("Client:InputThread started");

      while (true) {
        data.setLength(0);
        boolean timeout = false;
        try {
          if (this.readTimeout > 0L) {
            this.socket.setSoTimeout((int) this.readTimeout);
          }
          ClientSocketThread.socketReadLine(this.socket, -1, data);
        } catch (InterruptedIOException ee) { // SocketTimeoutException ee) {
          // error("Read interrupted (timeout) ...");
          if (getRunStatus() != THREAD_RUNNING) {
            break;
          }
          timeout = true;
          // continue;
        } catch (Throwable t) {
          Print.logError("Client:InputThread - " + t);
          t.printStackTrace();
          break;
        }
        if (!timeout || (data.length() > 0)) {
          ClientSocketThread.this.handleMessage(data.toString());
        }
      }

      synchronized (this.threadLock) {
        this.isRunning = false;
        Print.logDebug("Client:InputThread stopped");
        this.threadLock.notify();
      }
    }
Пример #28
0
 public void cutPlaylist() throws Exception {
   if (logger.isDebugEnabled()) logger.debug("Cut Playlist.");
   String st;
   PrintWriter pw =
       new PrintWriter(new BufferedWriter(new FileWriter(new File(this.NAME + ".dec"))));
   BufferedReader br = new BufferedReader(new FileReader(new File(this.NAME)));
   if ((st = br.readLine()) != null) {
     String st2[];
     st = new File(st).toURL().toString();
     st2 = st.split("/");
     StringBuffer stb = new StringBuffer(st2[st2.length - 1]);
     StringBuffer stb2 = stb.reverse();
     String st3 = new String(stb2);
     int i = 0;
     while (st3.charAt(i) != '.') i++;
     String a = st3.substring(i + 1, st3.length());
     pw.print(new StringBuffer(a).reverse());
   }
   while ((st = br.readLine()) != null) {
     pw.println();
     String st2[];
     st = new File(st).toURL().toString();
     st2 = st.split("/");
     StringBuffer stb = new StringBuffer(st2[st2.length - 1]);
     StringBuffer stb2 = stb.reverse();
     String st3 = new String(stb2);
     int i = 0;
     while (st3.charAt(i) != '.') i++;
     String a = st3.substring(i + 1, st3.length());
     pw.print(new StringBuffer(a).reverse());
   }
   pw.close();
   br.close();
 }
Пример #29
0
  /**
   * @param section
   * @param index
   * @return
   * @throws IOException
   */
  final String getStringFromSection(final Section section, final int index) throws IOException {
    if (index > section.getSize()) {
      return "";
    }

    final StringBuffer str = new StringBuffer();
    // Most string symbols will be less than 50 bytes in size
    final byte[] tmp = new byte[50];

    this.efile.seek(section.getFileOffset() + index);
    while (true) {
      int len = this.efile.read(tmp);
      for (int i = 0; i < len; i++) {
        if (tmp[i] == 0) {
          len = 0;
          break;
        }
        str.append((char) tmp[i]);
      }
      if (len <= 0) {
        break;
      }
    }

    return str.toString();
  }
Пример #30
0
 /** @return nick(id) */
 public String getNickAndId() {
   StringBuffer sb = new StringBuffer(getNick());
   sb.append('(');
   sb.append(Long.toString(getId()));
   sb.append(')');
   return sb.toString();
 }