Extension - if...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
public class Extension { public static void main(String[] args) { System.out.print("Enter a word: "); String filename = IO.readString(); int period = filename.lastIndexOf("."); if (period == -1) { System.out.println("Unknown file type."); return; } String extension = filename.substring(period);
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: if (extension.equalsIgnoreCase(".java")) { System.out.println("Java program"); } else if (extension.equalsIgnoreCase(".class")) { System.out.println("compiled Java executable"); } else { System.out.println("Unknown extension"); } } }...
View Full Document

This note was uploaded on 11/03/2009 for the course CS 01-111 taught by Professor Pradiphari during the Fall '09 term at Rutgers.

Ask a homework question - tutors are online