devdaily home | apple | java | perl | unix | directory | blog

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Other links

The source code

package com.swabunga.util;

public class StringUtility {
  public static StringBuffer replace(StringBuffer buf, int start, int end, String text) {
    int len = text.length();
    char[] ch = new char[buf.length() + len - (end - start)];
    buf.getChars(0, start, ch, 0);
    text.getChars(0, len, ch, start);
    buf.getChars(end, buf.length(), ch, start + len);
    buf.setLength(0);
    buf.append(ch);
    return buf;
  }

  public static void main(String[] args) {
    System.out.println(StringUtility.replace(new StringBuffer(args[0]), Integer.parseInt(args[2]), Integer.parseInt(args[3]), args[1]));
  }
}




Copyright 1998-2008 Alvin Alexander
All Rights Reserved.
 
devdaily.com is based in louisville, kentucky, and this web site is hosted by godaddy.com