SHARE
TWEET

Untitled

a guest Mar 25th, 2019 207 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top