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


Java StringBuffer類代碼示例

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


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

示例1: testText

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

示例2: testText

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

示例3: okToWriteThisEdge

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

示例4: calculateSignature

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

示例5: 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

示例6: 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

示例7: 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

示例8: notifyRegisterFiles

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

示例9: dumpOidNamesSymbolTable

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

示例10: 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

示例11: setUp

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

示例12: 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

示例13: displayVersion

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

示例14: 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

示例15: 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


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