Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. package ex;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class trying {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. String text = scanner.nextLine();
  10. String finName = text.substring(text.lastIndexOf('\\') + 1);
  11. System.out.println(finName);
  12. String[] words = finName.split(".");
  13. String name = words[0];
  14. String extension = words[1];
  15.  
  16. System.out.printf("File name: %s\n", name);
  17. System.out.printf("File extension: %s\n", extension);
  18.  
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement