code: public static void writeFile(final String dir, final String filename, String content, boolean debug) {
          // skip debug files when not in debug mode
          if (debug && !VoltCompiler.DEBUG_MODE) {
              return;
          }
  
          // cache the root of the folder for the debugoutput and the statement-plans folder
          if (m_debugRoot == null) {
              if (System.getenv("TEST_DIR") != null) {
                  m_debugRoot = System.getenv("TEST_DIR") + File.separator + debugRootPrefix;
              } else {
                  m_debugRoot = debugRootPrefix;
              }
          }
          if (m_userRoot == null) {
              if (System.getenv("TEST_DIR") != null) {
                  m_userRoot = System.getenv("TEST_DIR") + File.separator + userRootPrefix;
              } else {
                  m_userRoot = userRootPrefix;
              }
          }
  
          // pic a place for the file based on debugness of the file in question
          String root = debug ? m_debugRoot : m_userRoot;
  
          // don't call mkdirs more than once per subdir, so keep a cache
          String subFolderPath = root;
          if (dir != null) {
              subFolderPath += File.separator + dir;
          }
          if (!m_seenPaths.contains(subFolderPath)) {
              File f = new File(subFolderPath);
              f.mkdirs();
              m_seenPaths.add(subFolderPath);
          }
  
          String filepath = subFolderPath + File.separator + filename;
          File f = new File(filepath);
          PrintStream streamOut = null;
          try {
              streamOut = new PrintStream(f);
          } catch (FileNotFoundException e) {
              e.printStackTrace();
              return;
          }
          streamOut.println(content);
          streamOut.close();
      }
docs: Write a file to disk during compilation that has some neato info generated during compilation.
  If the debug flag is true, that means this file should only be written if the compiler is
  running in debug mode.