project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Utils.java
equal
deleted
inserted
replaced
268 return new String(os.toByteArray()); |
268 return new String(os.toByteArray()); |
269 } finally { |
269 } finally { |
270 closeQuietly(is); |
270 closeQuietly(is); |
271 } |
271 } |
272 } |
272 } |
|
273 |
|
274 private static final char[] badFilenameChars = new char[] { '/', '\\', ':', '*', '?', '\"', '<', '>', '|', '.', '\0' }; |
|
275 |
|
276 /** |
|
277 * Modify the given String so that it can be used as part of a filename |
|
278 * without causing problems from illegal/special characters. |
|
279 * |
|
280 * The result should be similar to the input, but isn't necessarily |
|
281 * reversible. |
|
282 */ |
|
283 public static String replaceBadChars(String name) { |
|
284 if (name == null || name.trim().length()==0) { |
|
285 return "_"; |
|
286 } |
|
287 name = name.trim(); |
|
288 for (char badChar : badFilenameChars) { |
|
289 name = name.replace(badChar, '_'); |
|
290 } |
|
291 return name; |
|
292 } |
273 } |
293 } |