Java Utililty Methods FileOutputStream Write

List of utility methods to do FileOutputStream Write

Description

The list of methods to do FileOutputStream Write are organized into topic(s).

Method

voidsaveFile(final InputStream in, final String path, final String fileName)
save File
OutputStream os = null;
try {
    File distDir = new File(path);
    if (!distDir.exists()) {
        distDir.mkdirs();
    os = new FileOutputStream(new File(distDir, fileName));
    byte[] buffer = new byte[256];
...
voidsaveFile(final String filename, final String s1, final String textOut, final String s3)
Save the given text out to the given file.
if ((filename != null) && (filename.length() > 0)) {
    final File file = new File(filename);
    file.mkdirs();
final File file1 = new File(
        String.valueOf((new StringBuffer(String.valueOf(filename))).append(s1).append(s3)));
System.out.println("write file ".concat(String.valueOf(file1)));
if (file1.exists()) {
...
voidsaveFile(InputStream is, File file)
save File
file.getParentFile().mkdirs();
file.createNewFile();
FileOutputStream outstream = new FileOutputStream(file);
int c;
while ((c = is.read()) != -1) {
    outstream.write(c);
outstream.close();
...
voidsaveFile(InputStream is, String destDir, String fileName)
save File
BufferedInputStream bis = new BufferedInputStream(is);
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(new File(destDir + fileName)));
int len = -1;
while ((len = bis.read()) != -1) {
    bos.write(len);
    bos.flush();
bos.close();
...
voidsavefile(InputStream source, String destination)
savefile
FileOutputStream fos = new FileOutputStream(destination);
int size = 0;
byte[] data = new byte[4096];
while (true) {
    size = source.read(data);
    if (size < 0)
        break;
    fos.write(data, 0, size);
...
voidsaveFile(InputStream uploadedInputStream, String serverLocation)
Save uploaded file to a defined location on the server
try {
    OutputStream outpuStream = new FileOutputStream(new File(serverLocation));
    int read = 0;
    byte[] bytes = new byte[1024];
    outpuStream = new FileOutputStream(new File(serverLocation));
    while ((read = uploadedInputStream.read(bytes)) != -1) {
        outpuStream.write(bytes, 0, read);
    outpuStream.flush();
    outpuStream.close();
} catch (IOException e) {
    e.printStackTrace();
FilesaveFile(String content, String path)
save File
BufferedOutputStream stream = null;
File file = null;
try {
    file = new File(path);
    if (!file.exists())
        file.createNewFile();
    FileOutputStream fstream = new FileOutputStream(file);
    stream = new BufferedOutputStream(fstream);
...
voidsaveFile(String desEncryptTempFile, byte[] text)
save File
try {
    FileOutputStream outSTr = new FileOutputStream(new File(desEncryptTempFile));
    BufferedOutputStream buff = new BufferedOutputStream(outSTr);
    buff.write(text);
    buff.flush();
    buff.close();
    outSTr.close();
} catch (Exception e) {
...
voidsaveFile(String destinationFile, String contents)
save File
OutputStream os = new FileOutputStream(destinationFile);
os.write(contents.getBytes());
os.close();
booleansaveFile(String dir, String fileName, String data)
save File
return saveFile(dir, fileName, data, false, false);