Linux: change temporary directory for Android Studio

Using Android Studio the directory used by the system to store temporary files (the default one is /tmp) could be filled by many (big) files, in order to limit this behaviour you can choose another directory to be used by the IDE. To do so you could launch the IDE every time with the following commands (in a terminal):
export _JAVA_OPTIONS=-Djava.io.tmpdir=/directory/to/use
/directory_android/bin/studio.sh
Remember to replace all paths  with the correct values, on my linux box i use:
export _JAVA_OPTIONS=-Djava.io.tmpdir=/opt/android-studio/tmp
/opt/android-studio/bin/studio.sh
You could also put everyting into a single script file:
#/bin/bash
export _JAVA_OPTIONS=-Djava.io.tmpdir=/opt/android-studio/tmp
/opt/android-studio/bin/studio.sh