Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
1,029
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.58 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.*;
  4.  
  5. public class Main
  6. {
  7.  
  8.     public static void main(String[] args)
  9.     {
  10.             Scanner scr = new Scanner(System.in);
  11.  
  12.             String line = scr.nextLine();
  13.             String[] arr = line.split("\\\\");
  14.             String file = arr[arr.length - 1];
  15.  
  16.             String fileName = file.substring(0, file.lastIndexOf('.'));
  17.             String fileExtension  = file.substring(file.lastIndexOf('.') + 1);
  18.  
  19.             System.out.println(String.format("File name: %s\nFile extension: %s", fileName, fileExtension));
  20.  
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement