I received an email yesterday and learned that I want to attend a product department meeting. I guess it may be because of the demo problem of this product. So I got busy until half past three yesterday, and I realized that I was being played again in the morning. MM sent the email to me by mistake. Miserable reminder! I am still too connected...
However, yesterday, I spent half a day on file operations, obtaining file extensions, removing file extensions, and so on. Now, let's learn from each other. If it is not well written, please make a brick.
/** Java file operation to get the file extension ** created on: 2011-8-2 * Author: blueeagle */public static string getextensionname (string filename) {If (filename! = NULL) & (filename. length ()> 0) {int dot = filename. lastindexof ('. '); If (DOT>-1) & (DOT <(filename. length ()-1) {return filename. substring (DOT + 1) ;}} return filename;}/** Java file operation to obtain the file name without the extension ** created on: 2011-8-2 * Author: blueeagle */public static string getfilenamenoex (string filename) {If (filename! = NULL) & (filename. length ()> 0) {int dot = filename. lastindexof ('. '); If (DOT>-1) & (DOT <(filename. length () {return filename. substring (0, dot) ;}} return filename ;}
Here we mainly use two functions: lastindexof (string) and substring (INT, INT ).