Java 类java.lang.StringBuffer 实例源码

项目:OSWf-OSWorkflow-fork    文件:AbstractTestClass.java   
@Test
public void testText() {

    final int size = 10000;
    StringBuffer buffer = new StringBuffer(size);

    for (int i=0; i<size; i++)
        buffer.append("A");

    propertySet.setText("text", buffer.toString());
    propertySet.setText("text-empty", "");
    propertySet.setText("text-null", null);
    propertySet.setText("text-100", "100");

    assertEquals(10000, propertySet.getText("text").length());
    assertNull(propertySet.getText("non.existent.key"));

    if (propertySet.supportsType(Type.TEXT)) 
        assertEquals(Type.TEXT, propertySet.getType("text"));
}
项目:OSWf-OSWorkflow-fork    文件:AbstractTestClass.java   
@Test
public void testText() {

    final int size = 10000;
    StringBuffer buffer = new StringBuffer(size);

    for (int i=0; i<size; i++)
        buffer.append("A");

    persistentVars.setText("text", buffer.toString());
    persistentVars.setText("text-empty", "");
    persistentVars.setText("text-null", null);
    persistentVars.setText("text-100", "100");

    assertEquals(10000, persistentVars.getText("text").length());
    assertNull(persistentVars.getText("non.existent.key"));

    if (persistentVars.supportsType(Type.TEXT)) 
        assertEquals(Type.TEXT, persistentVars.getType("text"));
}
项目:OSWf-OSWorkflow-fork    文件:Graphviz.java   
private boolean okToWriteThisEdge(ActionDescriptor action, ResultDescriptor result) {

        if(action.isCommon()) {
            String hash = new StringBuffer()
                .append(result.getStep())
                .append("-")
                .append(action.getId())
                .toString();

            if(commonStepsUsed.contains(hash) == false) {                    
                commonStepsUsed.add(hash);
                return true;
            } else
                return false;
        } else
            return true;
    }
项目:qcloudsms_java    文件:SmsSenderUtil.java   
public static String calculateSignature(String appkey, long random, long time,
        String[] phoneNumbers) {

    StringBuffer buffer = new StringBuffer("appkey=")
        .append(appkey)
        .append("&random=")
        .append(random)
        .append("&time=")
        .append(time)
        .append("&mobile=");

    if (phoneNumbers.length > 0) {
        buffer.append(phoneNumbers[0]);
        for (int i = 1; i < phoneNumbers.length; i++) {
            buffer.append(",");
            buffer.append(phoneNumbers[i]);
        }
    }

    return sha256(buffer.toString());
}
项目:Krill    文件:TermInfo.java   
public String toString () {
    this.analyze();

    StringBuffer sb = new StringBuffer();
    sb.append('<').append(this.getType()).append('>');
    sb.append(this.getFoundry()).append('/').append(this.getLayer());

    if (this.getValue() != null)
        sb.append(':').append(this.getValue());

    if (this.getDepth() != (byte) 0)
        sb.append('(').append(this.getDepth()).append(')');

    sb.append('[').append(this.getStartPos());
    sb.append('-').append(this.getEndPos()).append(']');
    sb.append('[').append(this.getStartChar());
    sb.append('-').append(this.getEndChar()).append(']');

    return sb.toString();
}
项目:tsugi-java    文件:TsugiUtils.java   
public static String dumpProperties(Properties p)
{
    if ( p == null ) return "Null Properties";
    StringBuffer sb = new StringBuffer();

    TreeMap sm = new TreeMap(p);
    Set keySet = sm.keySet();
    Iterator iter = keySet.iterator();
    while (iter.hasNext()) {
        String key = (String)iter.next();
        String value = (String)sm.get(key);
        if ( key.indexOf("secret") >= 0 ) value = "** suppressed ("+value.length()+") **";
        if ( sb.length() > 0 ) sb.append("\n");
        sb.append(key);
        sb.append(": ");
        sb.append(value);
    }
    if ( sb.length() < 1 ) sb.append("Empty Properties");
    return sb.toString();
}
项目:cloudera-homework    文件:IndexMapper.java   
@Override
public void map(Text key, Text value, Context context) throws IOException, InterruptedException
{
 FileSplit fileSplit = (FileSplit) context.getInputSplit();
 Path path = fileSplit.getPath();
 String fileName = path.getName();

 String line = value.toString();
 StringBuffer buffer = new StringBuffer();
 buffer.append(fileName);
 buffer.append('@');
 buffer.append(key);
 Text newValue = new Text(buffer.toString());
 for (String word : line.split("\\W+"))
 {
     if (word.length() > 0)
     {
      context.write(new Text(word), newValue); //newvalue = fileName+"@"+key;
     }
 }
}
项目:HentaiAtHome-Mirror    文件:ServerHandler.java   
public void notifyRegisterFiles(List<HVFile> pendingRegister) {
    int registerCount = pendingRegister.size();

    Out.debug("Notifying server of " + registerCount + " registered files...");

    StringBuffer sb = new StringBuffer();
    while(registerCount > 0) {
        sb.append((sb.length() > 0 ? ";" : "") + pendingRegister.remove(--registerCount).getFileid());
    }

    URL registerURL = getServerConnectionURL(ACT_FILE_REGISTER, sb.toString());
    ServerResponse sr = ServerResponse.getServerResponse(registerURL, this);

    if(sr.getResponseStatus() == ServerResponse.RESPONSE_STATUS_OK) {
        Out.debug("Register notification successful.");
    }
    else {
        Out.warning("Register notification failed.");
    }
}
项目:opennmszh    文件:SimpleNode.java   
/**
 * Dump the oidNames symbol tables - primarily debugging routine
 */
public void dumpOidNamesSymbolTable() {

  StringBuffer sb = new StringBuffer();
  OidValues oidValues = null;
  String key = null;
  String oidName = null;

  sb.append("Symbol Table oidNames for text OID/OidValues\n");
  for (Enumeration e = oidNames.keys(); e.hasMoreElements(); ) {
    key = (String) e.nextElement();
    oidValues = (OidValues) oidNames.get(key);
    sb.append(key + "/" + oidValues.toString()).append("\n");
  }

  if (printDebug) {
    System.out.println(sb.toString());
  }
}
项目:mephistobackup    文件:Backup.java   
/**
 * Returns a String generated by asking the user for the type of
 * files that want to be excluded in the final tar. Uses StringBuffer
 * for efficiency in appending excludes.
 * @return  a formatted exclude String for tar
 */
public static String getExcludes() {
    StringBuffer excluded = new StringBuffer();
    String question = "Filetype/Directory to exclude i.e. *.txt to skip all .txt files (. to end): ";
    MephUtil.messageparser(question, 0);
    MephUtil.userinputparser();
    String inputExclude = Settings.getInput();

    // only exit when we see only a dot
    while (!inputExclude.equals(".")) {
        excluded.append(EXCLUDE_STATEMENT + inputExclude + " ");

        MephUtil.messageparser(question, 0);
        MephUtil.userinputparser();
        inputExclude = Settings.getInput();
    }
    return excluded.toString();
}
项目:bugsnag-java    文件:ServletCallbackTest.java   
/**
 * Generate a new request instance which will be read by the servlet
 * context and callback
 */
@Before
public void setUp() {
    HttpServletRequest request = mock(HttpServletRequest.class);

    Map<String, String[]> params = new HashMap<String, String[]>();
    params.put("account", new String[]{"Acme Co"});
    params.put("name", new String[]{"Bill"});
    when(request.getParameterMap()).thenReturn(params);

    when(request.getMethod()).thenReturn("PATCH");
    when(request.getRequestURL()).thenReturn(new StringBuffer("/foo/bar"));
    when(request.getRequestURI()).thenReturn("/foo/bar");
    when(request.getRemoteAddr()).thenReturn("12.0.4.57");

    Enumeration<String> headers = new Vector<String>(
            Arrays.asList("Content-Type", "Content-Length")).elements();
    when(request.getHeaderNames()).thenReturn(headers);
    when(request.getHeader("Content-Type")).thenReturn("application/json");
    when(request.getHeader("Content-Length")).thenReturn("54");

    ServletContext context = mock(ServletContext.class);
    BugsnagServletRequestListener listener = new BugsnagServletRequestListener();
    listener.requestInitialized(new ServletRequestEvent(context, request));
}
项目:build-management    文件:CMnPatchTool.java   
/**
 * Translate the JDK information from the build data into a two digit
 * version number that can be used by the build scripts.
 *
 * @param    build    Build information
 * @return   Two digit version number (1.7, 1.6, 1.5, etc)
 */
private String getJdkVersion(CMnBuildData build) {
    String shortVersion = null;

    // We only care about the first two digits of the JDK
    StringBuffer sb = new StringBuffer();
    String version = build.getJdkVersion();
    if (version != null) {
        StringTokenizer st = new StringTokenizer(version, ".");
        if (st.countTokens() > 1) {
            sb.append(st.nextToken());
            sb.append(".");
            sb.append(st.nextToken());
        } else {
            sb.append(version);
        }
    } else {
        display("Unable to determine JDK version.");
        sb.append(version);
    }

    return sb.toString();
}
项目:build-management    文件:CMnPatchTool.java   
/**
 * Display the software version information to the user.
 */
public void displayVersion() {
    String manifest = "/META-INF/MANIFEST.MF";
    try {
        InputStream is = getClass().getResourceAsStream(manifest);
        InputStreamReader isr = new InputStreamReader(is);
        BufferedReader br = new BufferedReader(isr);
        StringBuffer sb = new StringBuffer();
        System.out.println("");
        String line;
        while ((line = br.readLine()) != null) {
            System.out.println(line);
        }
        br.close();
        isr.close();
        is.close();
    } catch (IOException ioex) {
        System.out.println("Failed to load version information from " + manifest);
        displayException(ioex);
    }
}
项目:OpenNMS    文件:SimpleNode.java   
/**
 * Dump the oidNames symbol tables - primarily debugging routine
 */
public void dumpOidNamesSymbolTable() {

  StringBuffer sb = new StringBuffer();
  OidValues oidValues = null;
  String key = null;
  String oidName = null;

  sb.append("Symbol Table oidNames for text OID/OidValues\n");
  for (Enumeration e = oidNames.keys(); e.hasMoreElements(); ) {
    key = (String) e.nextElement();
    oidValues = (OidValues) oidNames.get(key);
    sb.append(key + "/" + oidValues.toString()).append("\n");
  }

  if (printDebug) {
    System.out.println(sb.toString());
  }
}
项目:OpenNMS    文件:SimpleNode.java   
/**
 * Dump the oidNames symbol tables - primarily debugging routine
 */
public void dumpOidNamesSymbolTable() {

  StringBuffer sb = new StringBuffer();
  OidValues oidValues = null;
  String key = null;
  String oidName = null;

  sb.append("Symbol Table oidNames for text OID/OidValues\n");
  for (Enumeration e = oidNames.keys(); e.hasMoreElements(); ) {
    key = (String) e.nextElement();
    oidValues = (OidValues) oidNames.get(key);
    sb.append(key + "/" + oidValues.toString()).append("\n");
  }

  if (printDebug) {
    System.out.println(sb.toString());
  }
}
项目:OpenNMS    文件:SimpleNode.java   
/**
 * Dump the oidNames symbol tables - primarily debugging routine
 */
public void dumpOidNamesSymbolTable() {

  StringBuffer sb = new StringBuffer();
  OidValues oidValues = null;
  String key = null;
  String oidName = null;

  sb.append("Symbol Table oidNames for text OID/OidValues\n");
  for (Enumeration e = oidNames.keys(); e.hasMoreElements(); ) {
    key = (String) e.nextElement();
    oidValues = (OidValues) oidNames.get(key);
    sb.append(key + "/" + oidValues.toString()).append("\n");
  }

  if (printDebug) {
    System.out.println(sb.toString());
  }
}
项目:GitHub    文件:JfifTestUtils.java   
public static String encodeInt2HexString(int value, int length, boolean littleEndian) {
  StringBuffer sb = new StringBuffer();
  for (int i = 0; i < length; i++) {
    int oneByte = value & 0xFF;
    if (littleEndian) {
      sb.append(Hex.byte2Hex(oneByte));
    } else {
      sb.insert(0, Hex.byte2Hex(oneByte));
    }
    value = value >> 8;
  }
  return sb.toString();
}
项目:joai-project    文件:ResourceEmailer.java   
/**
 *  creates a comma delimitted display of the grade Range values
 *
 * @param  gr  an array of grade Ranges values
 * @return     comma delimited String
 */
private String gradeRangeStr(String[] gr) {
    if (gr == null) {
        return "";
    }
    StringBuffer s = new StringBuffer();
    for (int i = 0; i < gr.length; i++) {
        s.append(gr[i]);
        if (i < gr.length - 1) {
            s.append(", ");
        }
    }
    return s.toString();
}
项目:OSWf-OSWorkflow-fork    文件:AbstractTestClass.java   
@Test
public void testObject() {

    propertySet.setObject("object", new StringBuffer("Hello, world"));
    Object object = propertySet.getObject("object");

    assertTrue(object instanceof StringBuffer);

    assertEquals("Hello, world", ((StringBuffer)object).toString());
    assertNull(propertySet.getObject("non.existent.key"));

    if (propertySet.supportsType(Type.OBJECT)) 
        assertEquals(Type.OBJECT, propertySet.getType("object"));
}
项目:OSWf-OSWorkflow-fork    文件:AbstractTestClass.java   
@Test
public void testObject() {

    persistentVars.setObject("object", new StringBuffer("Hello, world"));
    Object object = persistentVars.getObject("object");

    assertTrue(object instanceof StringBuffer);

    assertEquals("Hello, world", ((StringBuffer)object).toString());
    assertNull(persistentVars.getObject("non.existent.key"));

    if (persistentVars.supportsType(Type.OBJECT)) 
        assertEquals(Type.OBJECT, persistentVars.getType("object"));
}
项目:OSWf-OSWorkflow-fork    文件:WfDefinitionServiceImpl.java   
private String xmlToHTML(String xml) {

    if(xml == null)
        return "";

    StringBuffer stringBuffer = new StringBuffer();

    stringBuffer.append("<div style='font-family:monospace; white-space:nowrap;'>");

    int len = xml.length();
    char c;

    for (int i = 0; i < len; i++) {
        c = xml.charAt(i);
        if (c == '<')
            stringBuffer.append("&lt;");
        else if (c == '\n')
            stringBuffer.append("<br />");
        else if (c == '\t')
            stringBuffer.append("&nbsp;&nbsp;");
        else if (c == ' ')
            stringBuffer.append("&nbsp;");
        else {
             // If 7 bit pass thru otherwise convert to unicode
            int ci = 0xffff & c;
            if (ci < 160 )
                stringBuffer.append(c);
            else {
                stringBuffer.append("&#");
                stringBuffer.append(new Integer(ci).toString());
                stringBuffer.append(';');
            }
        }
    }

    stringBuffer.append("</div>");

    return stringBuffer.toString();
}
项目:OSWf-OSWorkflow-fork    文件:HibernatePersistentVarsTest.java   
@Test
public void testObject() {
    createObject();
    Object object = persistentVars.getObject("object");

    assertTrue(object instanceof StringBuffer);

    assertEquals("Hello, world", ((StringBuffer)object).toString());
    assertEquals(Type.OBJECT, persistentVars.getType("object"));
    assertNull(persistentVars.getObject("non.existent.key"));
}
项目:OSWf-OSWorkflow-fork    文件:HibernatePersistentVarsTest.java   
protected void createTexts() {
    final int size = 10000;
    StringBuffer buffer = new StringBuffer(size);

    for (int i=0; i<size; i++)
        buffer.append("A");

    persistentVars.setText("text", buffer.toString());
    persistentVars.setText("text-empty", "");
    persistentVars.setText("text-null", null);
    persistentVars.setText("text-100", "100");
}
项目:qcloudsms_java    文件:SmsSenderUtil.java   
public static String calculateSignature(String appkey, long random, long time,
        String phoneNumber) {

    StringBuffer buffer = new StringBuffer("appkey=")
        .append(appkey)
        .append("&random=")
        .append(random)
        .append("&time=")
        .append(time)
        .append("&mobile=")
        .append(phoneNumber);

    return sha256(buffer.toString());
}
项目:qcloudsms_java    文件:SmsSenderUtil.java   
public static String calculateSignature(String appkey, long random, long time) {

        StringBuffer buffer = new StringBuffer("appkey=")
            .append(appkey)
            .append("&random=")
            .append(random)
            .append("&time=")
            .append(time);

        return sha256(buffer.toString());
    }
项目:OpenMobster    文件:DemoDetails.java   
/**
 * Finds the appropriate bean and sets it into the CommandContext for display
 */
public void doAction(CommandContext commandContext) 
{
    try
    {
        //Find the selected bean from the HomeScreen
        String channel = "offlineapp_demochannel";
        String selectedBean = (String)commandContext.getAttribute("selectedBean");

        //System.out.println("---------------------------------------");
        //System.out.println("Bean: "+selectedBean);
        //System.out.println("---------------------------------------");

        String details = null;

        //Lookup by state..in this case, that of 'demoString' field of the bean
        GenericAttributeManager criteria = new GenericAttributeManager();
        criteria.setAttribute("demoString", selectedBean);
        MobileBean[] beans = MobileBean.queryByEqualsAll(channel, criteria);
        MobileBean unique = beans[0];

        //Sets up the String that will be displayed
        StringBuffer buffer = new StringBuffer();
        buffer.append("DemoString: "+unique.getValue("demoString"));
        details = buffer.toString();

        //Sets up the state of the CommandContext
        commandContext.setAttribute("details", details);
    }
    catch(Exception e)
    {
        //e.printStackTrace(System.out);
        throw new RuntimeException(e.toString());
    }
}
项目:dls-repository-stack    文件:ResourceEmailer.java   
/**
 *  creates a comma delimitted display of the grade Range values
 *
 * @param  gr  an array of grade Ranges values
 * @return     comma delimited String
 */
private String gradeRangeStr(String[] gr) {
    if (gr == null) {
        return "";
    }
    StringBuffer s = new StringBuffer();
    for (int i = 0; i < gr.length; i++) {
        s.append(gr[i]);
        if (i < gr.length - 1) {
            s.append(", ");
        }
    }
    return s.toString();
}
项目:blogwow    文件:BlogWowDaoImpl.java   
/**
 * Turn an array into a string like "('item1','item2','item3')"
 * 
 * @param array
 * @return
 */
private String arrayToInString(Object[] array) {
   StringBuffer arrayString = new StringBuffer("('");
   for (int i = 0; i < array.length; i++) {
      if (i > 0)
         arrayString.append("','" + array[i]);
      else
         arrayString.append(array[i]);
   }
   arrayString.append("')");
   return arrayString.toString();
}
项目:arquitectura-software    文件:AbstractServlet.java   
protected JSONObject readJSON (BufferedReader bf) throws Exception{
    StringBuffer jb = new StringBuffer();
    String line = null;
    while ((line = bf.readLine()) != null){
        jb.append(line);
    }
    return JSONObject.fromObject(jb.toString());
}
项目:Download_It    文件:ImgurFrame.java   
private String normalizeText(String input) {

    StringBuffer normalized_text = new StringBuffer();

    for (int i = 0; i < input.length(); i++) {
        if (Character.isLetter(input.charAt(i)) || (Character.isDigit(input.charAt(i))) || Character.isWhitespace(input.charAt(i))) {
            normalized_text.append(input.charAt(i));
        }
    }        

    return normalized_text.toString();
}
项目:OpenKattis    文件:Yoda.java   
public static void main(String[] args) throws IOException {
    IO io = new IO(System.in);

    String[] input = {io.next(), io.next()};
    String[] output = {"",""};

    input[0] = leadingZeros(input[0], Math.max(input[0].length(), input[1].length()));
    input[1] = leadingZeros(input[1], Math.max(input[0].length(), input[1].length()));

    for (int i = 0; i <  Math.max(input[0].length(), input[1].length()); i++) {
        if ( getXToLastCharValue(input[0], i) > getXToLastCharValue(input[1], i) ) {
            output[0] = new StringBuffer(output[0]).insert(0, input[0].charAt(input[1].length() - i - 1)).toString();
        } else if ( getXToLastCharValue(input[0], i) < getXToLastCharValue(input[1], i) ) {
            output[1] = new StringBuffer(output[1]).insert(0, input[1].charAt(input[1].length() - i - 1)).toString();
        } else {
            output[0] = new StringBuffer(output[0]).insert(0, input[0].charAt(input[1].length() - i - 1)).toString();
            output[1] = new StringBuffer(output[1]).insert(0, input[1].charAt(input[1].length() - i - 1)).toString();
        }
    }

    for (int i = 0 ; i < 2; i++  ) {
        if (output[i].length() == 0) {
            output[i] = "YODA";
        } else if (Integer.parseInt(output[i]) == 0) {
            output[i] = "0";
        }
        io.println(output[i]);
    }


    io.close();
}
项目:JAVA-Overview    文件:cRunnableThread.java   
public static void main(String[] args)
{

    // Creates a Named Thread, just to indentify it

    ( new cThreadClass( new StringBuffer("first") ) ).start(); // In that case thread will run and after will free memory
    ( new cThreadClass( new StringBuffer("second") ) ).start(); 
}
项目:JAVA-Overview    文件:cThreadClass.java   
public static void main(String[] args)
{

    // Creates a Named Thread, just to indentify it

    ( new cThreadClass( new StringBuffer("first") ) ).start(); // In that case thread will run and after will free memory
    ( new cThreadClass( new StringBuffer("second") ) ).start(); 
}
项目:java-docs-samples    文件:TicTacToeServletTest.java   
@Before
public void setUp() throws Exception {
  MockitoAnnotations.initMocks(this);
  helper.setUp();
  dbSession = ObjectifyService.begin();

  // Set up a fake HTTP response.
  when(mockRequest.getRequestURL()).thenReturn(new StringBuffer("https://timbre/"));
  when(mockRequest.getRequestDispatcher("/WEB-INF/view/index.jsp")).thenReturn(requestDispatcher);

  servletUnderTest = spy(new TicTacToeServlet());

  helper.setEnvIsLoggedIn(true);
}
项目:fresco    文件:JfifTestUtils.java   
public static String encodeInt2HexString(int value, int length, boolean littleEndian) {
  StringBuffer sb = new StringBuffer();
  for (int i = 0; i < length; i++) {
    int oneByte = value & 0xFF;
    if (littleEndian) {
      sb.append(Hex.byte2Hex(oneByte));
    } else {
      sb.insert(0, Hex.byte2Hex(oneByte));
    }
    value = value >> 8;
  }
  return sb.toString();
}
项目:gocd-s3-artifacts    文件:GoEnvironment.java   
public String replaceVariables(String str) {
  Matcher m = envPat.matcher(str);

  StringBuffer sb = new StringBuffer();
  while (m.find()) {
    String replacement = get(m.group(1));
    if(replacement != null) {
      m.appendReplacement(sb, replacement);
    }
  }

  m.appendTail(sb);

  return sb.toString();
}
项目:HentaiAtHome-Mirror    文件:ServerHandler.java   
public void notifyUncachedFiles(List<HVFile> deletedFiles) {
    // note: as we want to avoid POST, we do this as a long GET. to avoid exceeding certain URL length limitations, we uncache at most 50 files at a time
    int deleteCount = deletedFiles.size();

    if(deleteCount > 0) {
        Out.debug("Notifying server of " + deleteCount + " uncached files...");

        do {
            StringBuffer sb = new StringBuffer();
            int limiter = 0;

            while(deleteCount > 0 && ++limiter <= 50) {
                sb.append((limiter != 1 ? ";" : "") + deletedFiles.remove(--deleteCount).getFileid());
            }

            URL uncacheURL = getServerConnectionURL(ACT_FILE_UNCACHE, sb.toString());
            ServerResponse sr = ServerResponse.getServerResponse(uncacheURL, this);

            if(sr.getResponseStatus() == ServerResponse.RESPONSE_STATUS_OK) {
                Out.debug("Uncache notification successful.");
            }
            else {
                Out.warning("Uncache notification failed.");
            }
        } while(deleteCount > 0);
    }
}
项目:HentaiAtHome-Mirror    文件:ServerHandler.java   
public String downloadFilesFromServer(Hashtable<String,String> files) {
    StringBuffer returnText = new StringBuffer();
    Enumeration<String> fileids = files.keys();

    try {
        while(fileids.hasMoreElements()) {
            String file = fileids.nextElement();
            String key = files.get(file);

            String[] s = file.split(":");
            String fileid = s[0];
            String host = s[1];

            // verify that we have valid ID and Key before we build an URL from it, in case the server has been compromised somehow...
            if(HVFile.isValidHVFileid(fileid) && key.matches("^[0-9]{6}-[a-z0-9]{40}$")) {
                URL source = new URL("http", host, 80, "/image.php?f=" + fileid + "&t=" + key);

                if(downloadAndCacheFile(source, fileid)) {
                    returnText.append(fileid + ":OK\n");
                }
                else {
                    returnText.append(fileid + ":FAIL\n");
                }
            }
            else {
                returnText.append(fileid + ":INVALID\n");
            }
        }
    } catch(Exception e) {
        e.printStackTrace();
        Out.warning("Encountered error " + e + " when downloading image files from server. Will not retry.");
    }

    return returnText.toString();
}
项目:knime4bio    文件:TabixReader.java   
public static String readLine(final InputStream is) throws IOException {
    StringBuffer buf = new StringBuffer();
    int c;
    while ((c = is.read()) >= 0 && c != '\n')
        buf.append((char)c);
    if (c < 0) return null;
    return buf.toString();
}
项目:journalApp    文件:Markdown.java   
public String parseChars(String allText) {
  char cursor;
  int lastEm = -1;
  int lastStrong = -1;
  StringBuffer text = new StringBuffer(allText);

  for (int i = 0; i < text.length(); i++) {
    cursor = text.charAt(i);

    switch (cursor) {
    case '_':
      //checks if previous was whitespace
      // is there two? (strong)
      if (text.charAt(i + 1) == '_') {
        // is this the left one?
        if (lastStrong == -1) {
          if (i - 1 < 0 || Character.isWhitespace(text.charAt(i - 1))) {
            lastStrong = i;
            // increment to get past double "__"
            i++;
          }
        } else {
          // i is on the left "_" of the closing "__"
          if (i + 2 > text.length() || Character.isWhitespace(text.charAt(i + 2))) {

            text = replaceSurrounding("__", "strong", lastStrong, i, text);

            lastStrong = -1;
          }
        }
      }

    }
  }

  return text.toString();
}