Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8766811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:38:37+00:00 2026-06-13T16:38:37+00:00

So I am working on a project that for certain reasons is limited to

  • 0

So I am working on a project that for certain reasons is limited to java squawk 1.4. Because of this, the String class does not contain the four methods in the title. I need those methods in my program, and have concluded that I have to make a Util class that performs the functions of those methods by itself.

First off, does this exist somewhere? Obviously my first reaction was to look into just copying the source from the String class, but the dependencies of those methods go far too deep for me to use.

Secondly, I am having trouble replicating the behaviour of split(String regex) and replace(CharSequence target, CharSequence replacement). contains(String) and isEmpty() are easy obviously, but I have run into trouble coding the others.

Right now, I have split working (Although it works in a different way than in jdk 7, and I do not want to get bugs).

public static String[] split(String string, char split) {
    String[] s = new String[0];
    int count = 0;
    for (int x = 0; x < string.length(); x++) {
        if (string.charAt(x) == split) {
            String[] tmp = s;
            s = new String[++count];
            System.arraycopy(tmp, 0, s, 0, tmp.length);
            s[count - 1] = string.substring(x).substring(1);
            if (contains(s[count - 1], split + "")) {
                s[count - 1] = s[count - 1].substring(0, s[count - 1].indexOf(split));
            }
        }
    }
    return s.length == 0 ? new String[]{string} : s;
}

Replace is much harder to do, and I have been trying for hours now. This seems to be a question google / archives have never even ventured.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T16:38:38+00:00Added an answer on June 13, 2026 at 4:38 pm

    Made the methods…

    public static boolean isEmpty(String string) {
        return string.length() == 0;
    }
    
    public static String[] split(String string, char split) {
        return _split(new String[0], string, split);
    }
    
    private static String[] _split(String[] current, String string, char split) {
        if (isEmpty(string)) {
            return current;
        }
        String[] tmp = current;
        current = new String[tmp.length + 1];
        System.arraycopy(tmp, 0, current, 0, tmp.length);
        if (contains(string, split + "")) {
            current[current.length - 1] = string.substring(0, string.indexOf(split));
            string = string.substring(string.indexOf(split) + 1);
        } else {
            current[current.length - 1] = string;
            string = "";
        }
        return _split(current, string, split);
    }
    
    public static boolean contains(String string, String contains) {
        return string.indexOf(contains) > -1;
    }
    
    public static String replace(String string, char replace, String replacement) {
        String[] s = split(string, replace);
    
        String tmp = "";
        for (int x = 0; x < s.length; x++) {
            if (contains(s[x], replace + "")) {
                tmp += s[x].substring(1);
            } else {
                tmp += s[x];
            }
        }
        return tmp;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently working on a project that involves crawling certain websites. However sometimes
I'm working on a Qt/C++ open source project that uses MySQL databases. One class
So I'm currently working on a project that needs to time when certain processes
I'm working on a project that is subject to certain corporate standards relating to
I have a working project that Im amending, it crashes after trying to use
I'm working on project that lets users choose some scientific authors and columnists and
Im working on a project that has an implementation of JOSSO in place. We
I'm working on a project that requires to convert html email into text. Below
I'm working on a project that downloads a zip file and unzips locally. The
I'm working on a project that is trying to use context-free grammars for parsing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.