Java 파일명에서 확장자 제외

1 개요[ | ]

Java 파일명에서 확장자 제외
Java
CPU
1.4s
MEM
71M
1.2s
Copy
public class MyClass {
    public static void main(String args[]) {
        String myfile = "hello.txt";
        System.out.println(myfile.replaceFirst("[.][^.]+$", ""));
    }
}
hello
Java
Copy
public class MyClass {
    public static void main(String args[]) {
        String myfile = "hello.txt.gz";
        System.out.println(myfile.replaceFirst("[.][^.]+$", ""));
    }
}
Loading

2 같이 보기[ | ]