Posted: 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.");