Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    private static final String FILE_NAME_PATTERN = "^(.+)\\.([^\\.]+)$";

    private static String sanitizeFileName(String fileName) {
        StringBuilder sanitized = new StringBuilder();
        sanitized.append(fileName.replaceAll(FILE_NAME_PATTERN, "$1").replaceAll("[^A-Za-z0-9_\\-]", "_"));
        sanitized.append(fileName.replaceAll(FILE_NAME_PATTERN, "$2"));
        return sanitized.toString();
    }
}