當前位置: 首頁>>代碼示例>>Java>>正文


Java StringBuffer.toString方法代碼示例

本文整理匯總了Java中java.lang.StringBuffer.toString方法的典型用法代碼示例。如果您正苦於以下問題:Java StringBuffer.toString方法的具體用法?Java StringBuffer.toString怎麽用?Java StringBuffer.toString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.lang.StringBuffer的用法示例。


在下文中一共展示了StringBuffer.toString方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: toString

import java.lang.StringBuffer; //導入方法依賴的package包/類
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();
}
 
開發者ID:KorAP,項目名稱:Krill,代碼行數:21,代碼來源:TermInfo.java

示例2: dumpProperties

import java.lang.StringBuffer; //導入方法依賴的package包/類
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();
}
 
開發者ID:tsugiproject,項目名稱:tsugi-java,代碼行數:21,代碼來源:TsugiUtils.java

示例3: map

import java.lang.StringBuffer; //導入方法依賴的package包/類
@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;
     }
 }
}
 
開發者ID:mellowonpsx,項目名稱:cloudera-homework,代碼行數:22,代碼來源:IndexMapper.java

示例4: getExcludes

import java.lang.StringBuffer; //導入方法依賴的package包/類
/**
 * 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();
}
 
開發者ID:rusher81572,項目名稱:mephistobackup,代碼行數:24,代碼來源:Backup.java

示例5: getJdkVersion

import java.lang.StringBuffer; //導入方法依賴的package包/類
/**
 * 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();
}
 
開發者ID:ModelN,項目名稱:build-management,代碼行數:30,代碼來源:CMnPatchTool.java

示例6: encodeInt2HexString

import java.lang.StringBuffer; //導入方法依賴的package包/類
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();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:14,代碼來源:JfifTestUtils.java

示例7: gradeRangeStr

import java.lang.StringBuffer; //導入方法依賴的package包/類
/**
 *  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();
}
 
開發者ID:NCAR,項目名稱:joai-project,代碼行數:20,代碼來源:ResourceEmailer.java

示例8: xmlToHTML

import java.lang.StringBuffer; //導入方法依賴的package包/類
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();
}
 
開發者ID:will-gilbert,項目名稱:OSWf-OSWorkflow-fork,代碼行數:40,代碼來源:WfDefinitionServiceImpl.java

示例9: doAction

import java.lang.StringBuffer; //導入方法依賴的package包/類
/**
 * 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());
	}
}
 
開發者ID:ZalemSoftware,項目名稱:OpenMobster,代碼行數:38,代碼來源:DemoDetails.java

示例10: arrayToInString

import java.lang.StringBuffer; //導入方法依賴的package包/類
/**
 * 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();
}
 
開發者ID:sakaicontrib,項目名稱:blogwow,代碼行數:18,代碼來源:BlogWowDaoImpl.java

示例11: normalizeText

import java.lang.StringBuffer; //導入方法依賴的package包/類
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();
}
 
開發者ID:shaungeorge,項目名稱:Download_It,代碼行數:13,代碼來源:ImgurFrame.java

示例12: replaceVariables

import java.lang.StringBuffer; //導入方法依賴的package包/類
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();
}
 
開發者ID:indix,項目名稱:gocd-s3-artifacts,代碼行數:16,代碼來源:GoEnvironment.java

示例13: downloadFilesFromServer

import java.lang.StringBuffer; //導入方法依賴的package包/類
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();
}
 
開發者ID:RyuaNerin,項目名稱:HentaiAtHome-Mirror,代碼行數:36,代碼來源:ServerHandler.java

示例14: readLine

import java.lang.StringBuffer; //導入方法依賴的package包/類
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();
}
 
開發者ID:lindenb,項目名稱:knime4bio,代碼行數:9,代碼來源:TabixReader.java

示例15: parseChars

import java.lang.StringBuffer; //導入方法依賴的package包/類
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();
}
 
開發者ID:jcjolley,項目名稱:journalApp,代碼行數:38,代碼來源:Markdown.java


注:本文中的java.lang.StringBuffer.toString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。