Inspectopedia Help

Hardcoded file separator

Reports the forward (/) or backward (\) slash in a string or character literal. These characters are commonly used as file separators, and portability may suffer if they are hardcoded.

The inspection will not report backward slashes inside escape sequences and forward slashes immediately following the '<' character or immediately preceding the '>' character, as those often indicate XML or HTML tags rather than file names. Strings representing a java.util.TimeZone ID, strings that are valid regular expressions, or strings that equal IANA-registered MIME media types will not be reported either.

Example:

new File("C:\\Users\\Name");

Use the option to include example/* in the set of recognized media types. Normally, usage of the example/* MIME media type outside of an example (e.g. in a Content-Type header) is an error.

Inspection options

Here you can find the description of settings available for the Hardcoded file separator inspection, and the reference of their default values.

Include 'example/*' in recognized MIME media types

Not selected

Ignore arguments for the following methods

None

Inspection Details

By default bundled with:

IntelliJ IDEA 2024.1, Qodana for JVM 2024.1,

Can be installed with plugin:

Java, 241.16690

Last modified: 29 April 2024