Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 HOw to check the extension in java
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
supahsain08




PostPosted: 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
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 1 Posts ]
Jump to:   


Style:  
Search: