import java.util.Scanner;
import java.util.StringTokenizer;
public class ExtractName {
/**
* @param args
*/
public static void main(String[] args) {
System.out.println("Enter the File Name with Location");
Scanner input=new Scanner(System.in);
String filePath=input.nextLine();
String fileName=null;
StringTokenizer tokens=new StringTokenizer(filePath,"\\");
while (tokens.hasMoreElements()) {
fileName=null;
fileName=(String) tokens.nextElement();
}
System.out.println("The File Name is "+fileName);
input.close();
}
}
import java.util.StringTokenizer;
public class ExtractName {
/**
* @param args
*/
public static void main(String[] args) {
System.out.println("Enter the File Name with Location");
Scanner input=new Scanner(System.in);
String filePath=input.nextLine();
String fileName=null;
StringTokenizer tokens=new StringTokenizer(filePath,"\\");
while (tokens.hasMoreElements()) {
fileName=null;
fileName=(String) tokens.nextElement();
}
System.out.println("The File Name is "+fileName);
input.close();
}
}
No comments:
Post a Comment