本文整理了Java中java.lang.StringBuffer.reverse()
方法的一些代码示例,展示了StringBuffer.reverse()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StringBuffer.reverse()
方法的具体详情如下:
包路径:java.lang.StringBuffer
类名称:StringBuffer
方法名:reverse
暂无
代码示例来源:origin: spring-projects/spring-framework
private void reverseStringBuffers() {
foo.reverse();
baz.reverse();
}
代码示例来源:origin: stackoverflow.com
public static boolean isPalindrome(String str) {
return str.equals(new StringBuffer().append(str).reverse().toString());
}
代码示例来源:origin: stackoverflow.com
String string="whatever";
String reverse = new StringBuffer(string).reverse().toString();
System.out.println(reverse);
代码示例来源:origin: spring-projects/spring-framework
@Override
public Object reimplement(Object obj, Method method, Object[] args) throws Throwable {
String s = (String) args[0];
return new StringBuffer(s).reverse().toString();
}
}
代码示例来源:origin: spring-projects/spring-framework
public String scramble(ProceedingJoinPoint pjp) throws Throwable {
String message = (String) pjp.proceed();
return new StringBuffer(message).reverse().toString();
}
代码示例来源:origin: ankidroid/Anki-Android
public static String incGuid(String guid) {
return new StringBuffer(_incGuid(new StringBuffer(guid).reverse().toString())).reverse().toString();
}
代码示例来源:origin: plutext/docx4j
private static String makeAlpha(int num) {
String letters = "abcdefghijklmnopqrstuvwxyz";
StringBuffer alphaNumber = new StringBuffer();
int base = 26;
int rem = 0;
num--;
if (num < base) {
alphaNumber.append(letters.charAt(num));
} else {
while (num >= base) {
rem = num % base;
alphaNumber.append(letters.charAt(rem));
num = num / base;
}
alphaNumber.append(letters.charAt(num - 1));
}
return alphaNumber.reverse().toString();
}
}
代码示例来源:origin: Javen205/IJPay
/**
* luhn算法
*
* @param number
* @return
*/
public static int genLuhn(String number) {
number = number + "0";
int s1 = 0, s2 = 0;
String reverse = new StringBuffer(number).reverse().toString();
for (int i = 0; i < reverse.length(); i++) {
int digit = Character.digit(reverse.charAt(i), 10);
if (i % 2 == 0) {// this is for odd digits, they are 1-indexed in //
// the algorithm
s1 += digit;
} else {// add 2 * digit for 0-4, add 2 * digit - 9 for 5-9
s2 += 2 * digit;
if (digit >= 5) {
s2 -= 9;
}
}
}
int check = 10 - ((s1 + s2) % 10);
if (check == 10)
check = 0;
return check;
}
}
代码示例来源:origin: ankidroid/Anki-Android
private String applyFixForHebrew(String text) {
// Track the regions of text that belong to a media reference so we can skip them.
// Modifying these regions would break the proper display/playback of the media.
List<Pair<Integer, Integer>> mediaRegions = new ArrayList<>();
for (Pattern p : Media.mRegexps) {
Matcher m = p.matcher(text);
while (m.find()) {
mediaRegions.add(new Pair<>(m.start(), m.end()));
}
}
Matcher m = sHebrewPattern.matcher(text);
StringBuffer sb = new StringBuffer();
while (m.find()) {
String hebrewText = m.group();
if (regionOverlapsMedia(mediaRegions, m.start(), m.end())) {
continue;
}
String reversed = new StringBuffer(hebrewText).reverse().toString();
String translated = translate(reversed);
m.appendReplacement(sb, "<span style=\"font-family:Tohu;\">" + translated + "</span>");
}
m.appendTail(sb);
return sb.toString();
}
代码示例来源:origin: FudanNLP/fnlp
if(t.equals("S") || t.equals("E")) {
if(pos != null) {
word.reverse();
al.add(new DynamicInfo(pos, word.toString(), word.toString().length()));
if(al.size() > DynamicTemplet.MAX)
word.reverse();
al.add(new DynamicInfo(pos, word.toString(), word.toString().length()));
代码示例来源:origin: spring-projects/spring-framework
@Test
public void serializableMethodReplacerAndSuperclass() throws Exception {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
reader.loadBeanDefinitions(DELEGATION_OVERRIDES_CONTEXT);
SerializableMethodReplacerCandidate s = (SerializableMethodReplacerCandidate) xbf.getBean("serializableReplacer");
String forwards = "this is forwards";
String backwards = new StringBuffer(forwards).reverse().toString();
assertEquals(backwards, s.replaceMe(forwards));
// SPR-356: lookup methods & method replacers are not serializable.
assertFalse(
"Lookup methods and method replacers are not meant to be serializable.",
SerializationTestUtils.isSerializable(s));
}
代码示例来源:origin: stackoverflow.com
public static void main(String[] args) {
// Using treditonal approach
String result="";
for (int i=string.length()-1; i>=0; i--) {
result = result + string.charAt(i);
}
System.out.println(result);
// Using StringBuffer class
StringBuffer buffer = new StringBuffer(string);
System.out.println(buffer.reverse());
}
代码示例来源:origin: stackoverflow.com
String s = "sample";
String result = new StringBuffer(s).reverse().toString();
代码示例来源:origin: geotools/geotools
/**
* Utility method used to reverse bits.
*
* <p>Since generating ID numbers is not performance critical I won't care right now.
*
* @param number
* @return Number represented as bits
*/
private static String asBits(long number) {
long yum = number;
StringBuffer buf = new StringBuffer(32);
for (int i = 0; i < 63; i++) {
buf.append(yum & 1);
yum = yum >> 1;
}
buf.reverse();
return buf.toString();
}
}
代码示例来源:origin: stackoverflow.com
public static Set<Integer> allPalindromic(int limit) {
Set<Integer> result = new HashSet<Integer>();
for (int i = 0; i <= 9 && i <= limit; i++)
result.add(i);
boolean cont = true;
for (int i = 1; cont; i++) {
StringBuffer rev = new StringBuffer("" + i).reverse();
cont = false;
for (String d : ",0,1,2,3,4,5,6,7,8,9".split(",")) {
int n = Integer.parseInt("" + i + d + rev);
if (n <= limit) {
cont = true;
result.add(n);
}
}
}
return result;
}
代码示例来源:origin: apache/opennlp
/**
* Get the SES required to go from a word to a lemma.
* @param wordForm the word
* @param lemma the lemma
* @return the shortest edit script
*/
public static String getShortestEditScript(String wordForm, String lemma) {
String reversedWF = new StringBuffer(wordForm.toLowerCase()).reverse().toString();
String reversedLemma = new StringBuffer(lemma.toLowerCase()).reverse().toString();
StringBuffer permutations = new StringBuffer();
String ses;
if (!reversedWF.equals(reversedLemma)) {
int[][]levenDistance = StringUtil.levenshteinDistance(reversedWF, reversedLemma);
StringUtil.computeShortestEditScript(reversedWF, reversedLemma, levenDistance, permutations);
ses = permutations.toString();
} else {
ses = "O";
}
return ses;
}
代码示例来源:origin: spring-projects/spring-framework
String reverse = new StringBuffer(s).reverse().toString();
assertEquals("Should have overridden to reverse, not echo", reverse, oom.replaceMe(s));
代码示例来源:origin: schemacrawler/SchemaCrawler
protected int feedFromInternalBuffer()
{
// feed out the buffer a character at a time
final int retChar = myBuffer.charAt(0);
myBuffer.reverse();
myBuffer.setLength(myBuffer.length() - 1);
myBuffer.reverse();
return retChar;
}
代码示例来源:origin: geotools/geotools
now = Long.parseLong(reverse.reverse().toString(), 2); // flip now around
代码示例来源:origin: camunda/camunda-bpm-platform
public void execute(DelegateExecution execution) {
String value1 = (String) text1.getValue(execution);
execution.setVariable("var1", new StringBuffer(value1).reverse().toString());
String value2 = (String) text2.getValue(execution);
execution.setVariable("var2", new StringBuffer(value2).reverse().toString());
}
内容来源于网络,如有侵权,请联系作者删除!