Saturday, 16 June 2012

File with extension and without extension


File with extension and without extension

package com.demo;

import java.io.File;

public class StringSample {
static private String name = "namratha.asher";

private static String getNameWithTxtExtension(File file) {
return file.getAbsolutePath()
+ ".txt";
}

private static String getNameWithoutExtension(File file) {
return file.getName();
}
public static void main(String[] args) {
System.out.println("string is "+name.lastIndexOf(".") );
String name = getNameWithTxtExtension(new File("c:/test"));
System.out.println("file with ext "+name);
String nameext = getNameWithoutExtension(new File("c:/test"));
System.out.println("file with out extn "+nameext);

}
}

No comments:

Post a Comment

Pass a HashMap from Angular Client to Spring boot API

This example is for the case where fileData is very huge and in json format   let map = new Map<string, string>()      map.set(this.ge...