/** Returns a buffered stream for writing to this file. Parent directories will be created if necessary. * @param append If false, this file will be overwritten if it exists, otherwise it will be appended. * @param bufferSize The size of the buffer. * @throws GdxRuntimeException if this file handle represents a directory, if it is a {@link FileType#Classpath} or * {@link FileType#Internal} file, or if it could not be written. */ public OutputStream write (boolean append, int bufferSize) { return new BufferedOutputStream(write(append), bufferSize); }
/** Returns a buffered stream for writing to this file. Parent directories will be created if necessary. * @param append If false, this file will be overwritten if it exists, otherwise it will be appended. * @param bufferSize The size of the buffer. * @throws GdxRuntimeException if this file handle represents a directory, if it is a {@link FileType#Classpath} or * {@link FileType#Internal} file, or if it could not be written. */ public OutputStream write (boolean append, int bufferSize) { return new BufferedOutputStream(write(append), bufferSize); }
/** Writes the specified bytes to the file. Parent directories will be created if necessary. * @param append If false, this file will be overwritten if it exists, otherwise it will be appended. * @throws GdxRuntimeException if this file handle represents a directory, if it is a {@link FileType#Classpath} or * {@link FileType#Internal} file, or if it could not be written. */ public void writeBytes (byte[] bytes, boolean append) { OutputStream output = write(append); try { output.write(bytes); } catch (IOException ex) { throw new GdxRuntimeException("Error writing file: " + file + " (" + type + ")", ex); } finally { StreamUtils.closeQuietly(output); } }
/** Writes the specified bytes to the file. Parent directories will be created if necessary. * @param append If false, this file will be overwritten if it exists, otherwise it will be appended. * @throws GdxRuntimeException if this file handle represents a directory, if it is a {@link FileType#Classpath} or * {@link FileType#Internal} file, or if it could not be written. */ public void writeBytes (byte[] bytes, int offset, int length, boolean append) { OutputStream output = write(append); try { output.write(bytes, offset, length); } catch (IOException ex) { throw new GdxRuntimeException("Error writing file: " + file + " (" + type + ")", ex); } finally { StreamUtils.closeQuietly(output); } }
/** Writes the specified bytes to the file. Parent directories will be created if necessary. * @param append If false, this file will be overwritten if it exists, otherwise it will be appended. * @throws GdxRuntimeException if this file handle represents a directory, if it is a {@link FileType#Classpath} or * {@link FileType#Internal} file, or if it could not be written. */ public void writeBytes (byte[] bytes, int offset, int length, boolean append) { OutputStream output = write(append); try { output.write(bytes, offset, length); } catch (IOException ex) { throw new GdxRuntimeException("Error writing file: " + file + " (" + type + ")", ex); } finally { StreamUtils.closeQuietly(output); } }
/** Writes the specified bytes to the file. Parent directories will be created if necessary. * @param append If false, this file will be overwritten if it exists, otherwise it will be appended. * @throws GdxRuntimeException if this file handle represents a directory, if it is a {@link FileType#Classpath} or * {@link FileType#Internal} file, or if it could not be written. */ public void writeBytes (byte[] bytes, boolean append) { OutputStream output = write(append); try { output.write(bytes); } catch (IOException ex) { throw new GdxRuntimeException("Error writing file: " + file + " (" + type + ")", ex); } finally { StreamUtils.closeQuietly(output); } }
@Override protected void processFile (Entry inputFile) throws Exception { filesScanned++; String content = new FileHandle(inputFile.inputFile).readString(); if (content.trim().startsWith("package")) { System.out.println("File '" + inputFile.inputFile + "' header fixed"); filesChanged++; BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileHandle(inputFile.outputFile).write(false))); writer.write(header + "\n\n" + content); writer.close(); } }
@Override protected void processFile (Entry inputFile) throws Exception { filesScanned++; String content = new FileHandle(inputFile.inputFile).readString(); if (content.trim().startsWith("package")) { System.out.println("File '" + inputFile.inputFile + "' header fixed"); filesChanged++; BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileHandle(inputFile.outputFile).write(false))); writer.write(header + "\n\n" + content); writer.close(); } }
static private void copyFile (FileHandle source, FileHandle dest) { try { dest.write(source.read(), false); } catch (Exception ex) { throw new GdxRuntimeException("Error copying source file: " + source.file + " (" + source.type + ")\n" // + "To destination: " + dest.file + " (" + dest.type + ")", ex); } }
public void write (FileHandle file, Pixmap pixmap) throws IOException { OutputStream output = file.write(false); try { write(output, pixmap); } finally { StreamUtils.closeQuietly(output); } }
public void write (FileHandle file, Pixmap pixmap) throws IOException { OutputStream output = file.write(false); try { write(output, pixmap); } finally { StreamUtils.closeQuietly(output); } }
static private void copyFile (FileHandle source, FileHandle dest) { try { dest.write(source.read(), false); } catch (Exception ex) { throw new GdxRuntimeException("Error copying source file: " + source.file + " (" + source.type + ")\n" // + "To destination: " + dest.file + " (" + dest.type + ")", ex); } }
@Override public void flush () { OutputStream out = null; try { out = new BufferedOutputStream(file.write(false)); properties.storeToXML(out, null); } catch (Exception ex) { throw new GdxRuntimeException("Error writing preferences: " + file, ex); } finally { StreamUtils.closeQuietly(out); } }
@Override public void flush () { OutputStream out = null; try { out = new BufferedOutputStream(file.write(false)); properties.storeToXML(out, null); } catch (Exception ex) { throw new GdxRuntimeException("Error writing preferences: " + file, ex); } finally { StreamUtils.closeQuietly(out); } }
@Override public void flush () { OutputStream out = null; try { out = new BufferedOutputStream(file.write(false)); properties.storeToXML(out, null); } catch (Exception ex) { throw new GdxRuntimeException("Error writing preferences: " + file, ex); } finally { StreamUtils.closeQuietly(out); } }
@Override public void flush () { OutputStream out = null; try { out = new BufferedOutputStream(file.write(false)); properties.storeToXML(out, null); } catch (Exception ex) { throw new GdxRuntimeException("Error writing preferences: " + file, ex); } finally { StreamUtils.closeQuietly(out); } }
@Override public void flush () { OutputStream out = null; try { out = new BufferedOutputStream(file.write(false)); properties.storeToXML(out, null); } catch (Exception ex) { throw new GdxRuntimeException("Error writing preferences: " + file, ex); } finally { StreamUtils.closeQuietly(out); } }
@Override public void flush () { OutputStream out = null; try { out = new BufferedOutputStream(file.write(false)); properties.storeToXML(out, null); } catch (Exception ex) { throw new GdxRuntimeException("Error writing preferences: " + file, ex); } finally { StreamUtils.closeQuietly(out); } }
/** Reads the remaining bytes from the specified stream and writes them to this file. The stream is closed. Parent directories * will be created if necessary. * @param append If false, this file will be overwritten if it exists, otherwise it will be appended. * @throws GdxRuntimeException if this file handle represents a directory, if it is a {@link FileType#Classpath} or * {@link FileType#Internal} file, or if it could not be written. */ public void write (InputStream input, boolean append) { OutputStream output = null; try { output = write(append); StreamUtils.copyStream(input, output); } catch (Exception ex) { throw new GdxRuntimeException("Error stream writing to file: " + file + " (" + type + ")", ex); } finally { StreamUtils.closeQuietly(input); StreamUtils.closeQuietly(output); } }
/** Reads the remaining bytes from the specified stream and writes them to this file. The stream is closed. Parent directories * will be created if necessary. * @param append If false, this file will be overwritten if it exists, otherwise it will be appended. * @throws GdxRuntimeException if this file handle represents a directory, if it is a {@link FileType#Classpath} or * {@link FileType#Internal} file, or if it could not be written. */ public void write (InputStream input, boolean append) { OutputStream output = null; try { output = write(append); StreamUtils.copyStream(input, output); } catch (Exception ex) { throw new GdxRuntimeException("Error stream writing to file: " + file + " (" + type + ")", ex); } finally { StreamUtils.closeQuietly(input); StreamUtils.closeQuietly(output); } }