Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package TextProcessingAndRegEx;
- import java.util.Scanner;
- public class ExtractFile {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String input = scanner.nextLine();
- int index = input.lastIndexOf("\\");
- String file = input.substring(index + 1);
- int index2 = file.lastIndexOf(".");
- String fileType =file.substring(index2+1);
- String fileName =file.substring(0,index2);
- System.out.println(String.format("File name: %s",fileName));
- System.out.println(String.format("File extension: %s",fileType));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement