Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static String[] split(String fileName) {
        StringBuffer nombre = new StringBuffer();
        StringBuffer extension = new StringBuffer();
        boolean ext = false;
        char[] cars = fileName.toCharArray();
        for (int i = 0; i < cars.length; i++) {
            if (cars[i] == '.') {
                if (ext) {
                    nombre.append('.');
                    nombre.append(extension.toString());
                    extension = new StringBuffer();
                } else {
                    ext = true;
                }
            } else {
                if (ext) {
                    extension.append(cars[i]);
                } else {
                    nombre.append(cars[i]);
                }
            }
        }
        String[] split = new String[2];
        split[0] = nombre.toString();
        split[1] = extension.toString();
        return split;
    }
}