Advertisement
jwrbg

asd

Apr 10th, 2019
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.54 KB | None | 0 0
  1. package TechModule;
  2.  
  3.         import java.util.Scanner;
  4.  
  5. public class p07_RegexExtractFile {
  6.     public static void main(String[] args) {
  7.         Scanner scanner=new Scanner(System.in);
  8.         String input = scanner.nextLine();
  9.  
  10.         String file=input.substring(input.lastIndexOf("\\")+1);
  11.  
  12.         String fileName=file.substring(0,file.indexOf('.'));
  13.         String fileExtension=file.substring(file.lastIndexOf('.')+1);
  14.  
  15.  
  16.  
  17.         System.out.println(String.format("File name: %s%nFile extension: %s",fileName,fileExtension));
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement