Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

replace string placeholder java

public static String dictFormat(String format, Hashtable<String, Object> values) {
    StringBuilder convFormat = new StringBuilder(format);
    Enumeration<String> keys = values.keys();
    ArrayList valueList = new ArrayList();
    int currentPos = 1;
    while (keys.hasMoreElements()) {
        String key = keys.nextElement(),
        formatKey = "%(" + key + ")",
        formatPos = "%" + Integer.toString(currentPos) + "$";
        int index = -1;
        while ((index = convFormat.indexOf(formatKey, index)) != -1) {
            convFormat.replace(index, index + formatKey.length(), formatPos);
            index += formatPos.length();
        }
        valueList.add(values.get(key));
        ++currentPos;
    }
    return String.format(convFormat.toString(), valueList.toArray());
}
Comment

replace string placeholder java

public static String dictFormat(String format, Hashtable<String, Object> values) {
    StringBuilder convFormat = new StringBuilder(format);
    Enumeration<String> keys = values.keys();
    ArrayList valueList = new ArrayList();
    int currentPos = 1;
    while (keys.hasMoreElements()) {
        String key = keys.nextElement(),
        formatKey = "%(" + key + ")",
        formatPos = "%" + Integer.toString(currentPos) + "$";
        int index = -1;
        while ((index = convFormat.indexOf(formatKey, index)) != -1) {
            convFormat.replace(index, index + formatKey.length(), formatPos);
            index += formatPos.length();
        }
        valueList.add(values.get(key));
        ++currentPos;
    }
    return String.format(convFormat.toString(), valueList.toArray());
}
Comment

PREVIOUS NEXT
Code Example
Java :: java include class 
Java :: how to run the war file in Apache Tomcat/8.5.59 THROUGH SPRING 
Java :: jdned 
Java :: dynamic fib 
Java :: diiferent ways to run spring boot 
Java :: public CustomAdapter(Context context, ArrayList<HashMap data, int resource, String[] from, int[] to) 
Java :: java tcp readline not working 
Java :: bipredicate in java 
Java :: java multi threading Buzzer program 
Java :: int p=10, q; switch(p) { case1: q=p*2; break; case2: q=p+2; break; case3: q=p-2; break; } 
Java :: v2ray 
Java ::         System.out.println("Welcone to GeeksforGeeks"); 
Java :: how do you create a txt file in java 
Java :: java.sql.SQLException: Invalid column index 
Java :: how to add data json jaca 
Java :: leftView 
Java :: get string match percentage java 
Java :: priority queue is empty java 
Java :: maven show runtime classpath 
Java :: Java Constructor invocations 
Java :: Java Public Access Modifier package one 
Java :: stack push java 
Java :: java get end of date 
Java :: OpenCV mat to float bytebuffer java 
Java :: java codigo para criar um aleatorio entre valores 
Java :: split string in / java 
Java :: pyqt tree view 
Java :: text with seek bar in android 
Java :: Automatic Code Completion in NetBeans 
Java :: Create dynamic tree view using JavaScript 
ADD CONTENT
Topic
Content
Source link
Name
8+8 =