SELECT ... INTO OUTFILE writes the selected rows to a file. Column and line terminators c
an be specified to produce a specific output format.

@param file file to write to
@return the current object
764620
@WithBridgeMethods(value = MySQLQuery.class, castRequired = true)
    public C intoOutfile(File file) {
        return addFlag(Position.END, "\ninto outfile '" + file.getPath() + "'");
    }
1049579
protected OutputStream createFileOutputStream(File file) {
    try {
      return new FileOutputStream(file);
    } catch (FileNotFoundException e) {
      throw new GenException(Message.DOMAGEN9001, e, e);
    }
  }
1233983
public File createFile(File file) throws DataUtilException {
        if(file == null) {
            throw new DataUtilException("File parameter can not be a null value");
        }

        try {
            if(! file.createNewFile()) {
                throw new DataUtilException("Failed to create file. Result of File.createNewFile() was false.");
            }
            trackedFiles.add(file);
        } catch (IOException e) {
            throw new DataUtilException("Failed to create file: " + file.getAbsolutePath(), e);
        }
        return file;
    }
1085644
private byte[] getExcelOutput(FileColumn[] columns, List<String[]> lines) throws IOException
    {
        // Create the workbook
        baos = new ByteArrayOutputStream(1024);
        if(existing != null)
            workbook = Workbook.createWorkbook(format, baos, existing);
        else
            workbook = Workbook.createWorkbook(format, baos);

        workbook.setHeaders(hasHeaders());

        if(append && workbook.getSheet(worksheet) != null)
            workbook.appendToSheet(columns, lines, worksheet);
        else
            workbook.createSheet(columns, lines, worksheet);

        // Write out the workbook to the stream
        workbook.write();
        workbook.close();

        // The contents returned is the byte array
        return baos.toByteArray();
    }
888668
public String readFileContent(File file) {
        StringBuilder fileContentBuilder = new StringBuilder();
        if (file.exists()) {
            String stringLine;
            try {
                FileReader fileReader = new FileReader(file);
                BufferedReader bufferedReader = new BufferedReader(fileReader);
                while ((stringLine = bufferedReader.readLine()) != null) {
                    fileContentBuilder.append(stringLine + "\n");
                }
                bufferedReader.close();
                fileReader.close();
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        return fileContentBuilder.toString();
    }
113594
public static void toFile(InputStream input, File file) throws IOException {
		OutputStream os = new FileOutputStream(file);
		int bytesRead = 0;
		byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
		while ((bytesRead = input.read(buffer, 0, DEFAULT_BUFFER_SIZE)) != -1) {
			os.write(buffer, 0, bytesRead);
		}
		IOUtils.closeQuietly(os);
		IOUtils.closeQuietly(input);
	}
1112198
private File processFile(File file) throws Exception {
        List<String> original = readFile(file);
        List<String> content = new ArrayList<>(original);
        BeanGen gen;
        try {
            BeanParser parser = new BeanParser(file, content, config);
            gen = parser.parse();
        } catch (BeanCodeGenException ex) {
            throw ex;
        } catch (Exception ex) {
            throw new BeanCodeGenException(ex.getMessage(), ex, file);
        }
        if (gen.isBean()) {
            if (verbosity >= 2) {
                System.out.print(file + "  [processing]");
            }
            gen.process();
            if (content.equals(original) == false) {
                if (write) {
                    if (verbosity >= 2) {
                        System.out.println(" [writing]");
                    } else if (verbosity == 1) {
                        System.out.println(file + "  [writing]");
                    }
                    writeFile(file, content);
                } else {
                    if (verbosity >= 2) {
                        System.out.println(" [changed not written]");
                    } else if (verbosity == 1) {
                        System.out.println(file + "  [changed not written]");
                    }
                }
                return file;
            } else {
                if (verbosity >= 2) {
                    System.out.println(" [no change]");
                }
            }
        } else {
            gen.processNonBean();
            if (!content.equals(original)) {
                if (write) {
                    if (verbosity >= 2) {
                        System.out.println(" [writing]");
                    } else if (verbosity == 1) {
                        System.out.println(file + "  [writing]");
                    }
                    writeFile(file, content);
                } else {
                    if (verbosity >= 2) {
                        System.out.println(" [changed not written]");
                    } else if (verbosity == 1) {
                        System.out.println(file + "  [changed not written]");
                    }
                }
                return file;
            } else {
                if (verbosity == 3) {
                    System.out.println(file + "  [ignored]");
                }
            }
        }
        return null;
    }
738560
private S getInputStreamForFile(File file) throws IOException {
        assert file != null : "File must be specified";
        return this.getInputStreamForRawStream(new FileInputStream(file));
    }
926450
public boolean dumpTo(File outFile) throws IOException {
        if (exists()) {
            dump(getOffset(), outFile);
            return true;
        } else {
            return false;
        }
    }
608949
public static Writer writer(File file) {
        try {
            return new FileWriter(file);
        } catch (IOException e) {
            throw E.ioException(e);
        }
    }
979322
public void setOutfile(final File outfile) {
    //
    // if file name was empty, skip link step
    //
    if (outfile == null || outfile.toString().length() > 0) {
      this.outFile = outfile;
    }
  }
203910
public static String readFile(File file) throws IOException {
        StringBuilder content = new StringBuilder();
        String line;
        try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
            while ((line = reader.readLine()) != null) {
                content.append(line).append("\r\n");
            }
        }
        return content.toString();
    }
540040
public static String readFile(File file) {
		FileInputStream inputStream;
		try {
			inputStream = new FileInputStream(file);
			return new String(readStream(inputStream));
		} catch (FileNotFoundException e) {
			JK.throww(e);
			return null;
		}
	}
855763
public static InputStream openFromFile(final File file) {
    try {
      InputStream is = new BufferedInputStream(new FileInputStream(file),
          BUFFER_SIZE);
      if (file.getName().endsWith(".gz") || file.getName().endsWith("gz")) {
        is = new GZIPInputStream(is, BUFFER_SIZE);
      }
      return is;
    } catch (final IOException e) {
      throw new TerminateToolException(-1,
          "File '" + file + "' cannot be found", e);
    }
  }
737953
public void writeTreesInOneLineFormat(File outFile) throws IOException {
        BufferedWriter writer = new BufferedWriter(new FileWriter(outFile));
        for (BinaryTree tree : this) {
            writer.write(tree.getAsOneLineString());
            writer.write("\n");
        }
        writer.close();        
    }
1280295
public static void copyFile(File from, File to) throws IOException {
        InputStream in = new BufferedInputStream(new FileInputStream(from));
        try {
            OutputStream out = new BufferedOutputStream(new FileOutputStream(to));
            try {
                IoUtils.copyAllBytes(in, out);
            } finally {
                IoUtils.safeClose(out);
            }
        } finally {
            IoUtils.safeClose(in);
        }
    }
1166037
public void write(File file) {
    FileOutputStream out = null;
    try {
      out = new FileOutputStream(file, false);
      workbook.write(out);
    } catch (FileNotFoundException e) {
      throw new RuntimeException(e);
    } catch (IOException e) {
      new RuntimeException(e);
    } finally {
      if (out != null)
        try {
          out.close();
        } catch (IOException e) {
          new RuntimeException(e);
        }
    }
  }