Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ex;
- import java.util.Scanner;
- public class trying {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String text = scanner.nextLine();
- String finName = text.substring(text.lastIndexOf('\\') + 1);
- System.out.println(finName);
- String[] words = finName.split(".");
- String name = words[0];
- String extension = words[1];
- System.out.printf("File name: %s\n", name);
- System.out.printf("File extension: %s\n", extension);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement