-
Notifications
You must be signed in to change notification settings - Fork 5
/
IoUtil.java
29 lines (25 loc) · 907 Bytes
/
IoUtil.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*
* © 2021. TU Dortmund University,
* Institute of Energy Systems, Energy Efficiency and Energy Economics,
* Research group Distribution grid planning and operation
*/
package edu.ie3.datamodel.io;
import java.io.File;
public class IoUtil {
public static final String FILE_SEPARATOR_REGEX = "[\\\\/]";
public static final String FILE_SEPARATOR_REPLACEMENT =
File.separator.equals("\\") ? "\\\\" : "/";
private IoUtil() {
throw new IllegalStateException("Utility classes cannot be instantiated");
}
/**
* Ensure to have harmonized file separator across the whole String. Will replace all occurrences
* of "\" and "/" by the systems file separator
*
* @param in The String to harmonize
* @return The harmonized String
*/
public static String harmonizeFileSeparator(String in) {
return in.replaceAll(FILE_SEPARATOR_REGEX, FILE_SEPARATOR_REPLACEMENT);
}
}