Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {

    public static String getSringBeforeChar(String sourceStr, char ch) {
        StringBuffer sb = new StringBuffer(sourceStr);
        StringBuffer newSb = new StringBuffer();
        for (int i = 0; i < sb.length(); i++) {
            if (sb.charAt(i) == ch) {
                break;
            }
            newSb.append(sb.charAt(i));
        }

        return newSb.toString();

    }
}