Computer Science Canada

HOw to check the extension in java

Author:  supahsain08 [ Fri Feb 22, 2008 11:02 am ]
Post subject:  HOw to check the extension in java

This is what i have to do

Write a program that prompts the user for a file name (including the extension), checks the extension and responds with a comment about the type of file, for example ?

.doc ? That was a Word document!
.xls ? That was an Excel spreadsheet!
.java ? That was a Java source file!


My code so far

code:
import java.util.Scanner;

import java.io.*;
class string
{
        public static void main(String[] args) throws Exception
        {
        Scanner in = new Scanner(System.in);


               
                String extension;
                System.out.println ("Please enter a file name with extension.");
               
                extension = in.nextLine();

                Scanner s = new Scanner(extension);


                s.findInLine(.doc);

                 
               

               
               
               
                if (s.equals(.doc))
                {
               
                System.out.println ("doc file.");
                }
                else
                {
               
                System.out.println ("none.");
                }
               
                }
                }


I can't seem to figure out, any ideas


: