title: How can I use AOP to intercept the constructor of File, FileReader, FileWriter, FileInputStream and FileOutputStream?
body: <p>I want to intercept the constructor of File, FileReader, FileWriter, FileInputStream and FileOutputStream and prevent any filenames from containing ".." (to prevent path traversal attacks) or "\0" (to prevent filename null character attacks).</p>
  
  <p>I have another open question about how to do this same thing using SecurityManager, but no one has answered it yet, so I was hoping this alternate method would work.</p>
  
  <p>This is for a spring webapp on tomcat.</p>
  
  <p>I know that I could manually do this by making my own SafeFile, SafeFileReader, etc., classes and modifying the code to use those instead. However, there are 960 places in our code that use the constructors for those objects, so I'd prefer to avoid that unless it's the only way.</p>