If you, like me, would rather use some library code where they probably have thought of all special cases, such as what happens if you pass in null or dots in the path but not in the filename, you can use the following:
import org.apache.commons.io.FilenameUtils; String fileNameWithOutExt = FilenameUtils.removeExtension(fileNameWithExt);
Related Posts:
- What is an instance variable in Java?
- super() in Java
- What’s the syntax for mod in java
- What does the Java assert keyword do, and when should it be used?
- How do I make a delay in Java?
- Casting variables in Java
- max value of integer
- How can I prevent java.lang.NumberFormatException: For input string: “N/A”?
- What is the difference between == and equals() in Java?
- What does “?” mean in Java?
- Java – No enclosing instance of type Foo is accessible
- Why I am getting java.lang.AbstractMethodError errors?
- How do I save a String to a text file using Java?
- fix java.net.SocketTimeoutException: Read timed out
- How to override equals method in Java
- java.text.ParseException: Unparseable date
- What is the best/simplest way to read in an XML file in Java application?
- Rename a file using Java
- Java – String cannot be converted to int
- java.io.IOException: Broken pipe
- java.util.NoSuchElementException: No line found
- The system cannot find the file specified in java
- Even though JRE 8 is installed on my MAC -” No Java Runtime present,requesting to install ” gets displayed in terminal
- Reason for the exception java.lang.VerifyError: Bad type on operand stack
- The specified DSN contains an architecture mismatch between the Driver and Application. JAVA
- Downcasting in Java
- Java “params” in method signature?
- How do I time a method’s execution in Java?
- Java can’t find file when running through Eclipse
- repaint() Method in Java
- Exception in thread “main” java.lang.reflect.InvocationTargetException
- How to set String’s font size, style in Java using the Font class?
- Invalid escape sequence (valid ones are \b \t \n \f \r \” \’ \\ )
- How to use the command update-alternatives –config java
- java array error “array required but int found”
- this: Cannot use this in static context
- What’s the difference between SoftReference and WeakReference in Java?
- How to draw lines in Java
- NoClassDefFoundError in Java: com/google/common/base/Function
- What is a .meta file and why does Unity create them for all of my assets?
- Java FileOutputStream Create File if not exists
- Downloading a file from spring controllers
- In Java, what is a shallow copy?
- Good way to encapsulate Integer.parseInt()
- Eclipse IDE – Error: Build path specifies execution environment Java SE 1.7
- Java: Not a statement
- ArrayList of int array in java
- How to read file from relative path in Java project? java.io.File cannot find the path specified
- How can I get the count of line in a file in an efficient way?
- Difference between java.io.PrintWriter and java.io.BufferedWriter?
- How can I catch all the exceptions that will be thrown through reading and writing a file?
- In Java, how do I parse XML as a String instead of a file?
- How can I upgrade to Java 1.8 on an Amazon Linux Server?
- How do I copy a file in Python?
- What does Java option -Xmx stand for? [duplicate]
- How do I copy a file in Python?
- How do I convert a String to an int in Java?
- What does Java option -Xmx stand for? [duplicate]
- Using prevNext Modx Addon
- Is there an invisible character that is not regarded as whitespace?
- Problem with gif with transparent background
- :wq! command in vim
- how to set the background color of the status bar during the launching phase [duplicate]
- Finding white rectangle in an image
- api-ms-win-crt-runtime-l1-1-0.dll is missing when opening Microsoft Office file [closed]
- 1000 * 60 * 60 * 24 * 30 results in a negative number [duplicate]
- How to convert nanoseconds to seconds using the TimeUnit enum?
- When is K 1024 and when is it 1000?
- Search for words with telephone numbers from 2-3-4 tree
- What is a MIME type?
- Logitech/LGHUB Lua – Loop with break
- are there dictionaries in javascript like python?
- How can I convert MP3 file to a Base64 encoded string? [closed]
- Understanding The Modulus Operator %
- Understanding the main method of python [duplicate]
- Dial pad to get phone number (with Android button images)
- TypeError: only integer scalar arrays can be converted to a scalar index with 1D numpy indices array
- How to open a file using the open with statement
- How is the AND/OR operator represented as in Regular Expressions?
- TypeError: only integer scalar arrays can be converted to a scalar index with 1D numpy indices array
- Using “with open() as file” method, how to write more than once? [duplicate]
- Istio Ingress resulting in “no healthy upstream”
- Using or ‘|’ in regex [duplicate]
- How to format strings in Java
- Why is it not possible to fake an IP address?
- How to open a “-” dashed filename using terminal?
- What is the difference between x86 and x64
- && (AND) and || (OR) in IF statements
- Substring in excel
- How to use the toString method in Java?
- What is a LAMP stack?
- What is a NullPointerException, and how do I fix it?
- What is a sanity test/check
- What is the difference between POST and PUT in HTTP?
- What exactly is Apache Camel?
- What is the difference between POST and PUT in HTTP?
- Unable to find valid certification path to requested target – error even after cert imported
- How to find Google’s IP address?
- What exactly is a VBO in OpenGL?
- What and where are the stack and heap?