I need to map invalid characters to some other characters like "/" to "\_" (forward slash to underscore) while creating a file because file name do not allowed to put slashes, question, double quotes etc.

Suppose I have

```
String name = "Message Test - 22/10/2016";

```

Now I want to write a file by using above string but it gives error because of slashes.

So I want to map slash like all the invalid characters to any other characters while writing a file. After writing, I need to read all the names of the files & show on the page.

SOMEHOW I MAP THE CHARACTERS, SO FILE NAME WOULD BE 

```
Message_Test_-_22-10-2016

```

When I show it on web I need to return file name as the original name like

```
Message Test - 22/10/2016

```

I am using java. Can anyone help me out of this how can I start writing this approach or Is there any api for it or Is there any other approach.

*I don't want to use database to co-related alias file name with original file name*