GeekVan

导航

filename extension

题目描述

Please create a function to extract the filename extension from the given path,return the extracted filename extension or null if none.

输入描述:

输入数据为一个文件路径

输出描述:

对于每个测试实例,要求输出对应的filename extension
示例1

输入

Abc/file.txt

输出

txt

 1 public class Mydemo {
 2     
 3     public static void main(String[] args) {
 4         // TODO Auto-generated method stub
 5         Scanner scan=new Scanner(System.in);
 6         while(true) {
 7         
 8         String s=scan.nextLine();
 9         int location=s.lastIndexOf(".");
10         char temp[]=s.toCharArray();
11         for(int i=0;i<s.length();i++) {
12             if(i>location) {
13                 System.out.print(temp[i]);
14             }
15         }
16         System.out.println();
17         
18         }
19                 
20         
21         
22     }
23 
24 }

 

posted on 2018-01-19 20:24  GeekVan  阅读(160)  评论(0编辑  收藏  举报