Java Utililty Methods File Write

List of utility methods to do File Write

  1. HOME
  2. Java
  3. F
  4. File Write

Description

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

Method

void fileWrite(String filename, byte[] ba)
file Write
FileOutputStream fos = new FileOutputStream(filename);
fos.write(ba);
fos.close();
void fileWrite(String fileName, String str)
file Write
File file = new File(fileName);
FileOutputStream fopstream = null;
try {
 fopstream = new FileOutputStream(file);
 fopstream.write(str.getBytes());
} catch (Exception e1) {
 e1.printStackTrace();
} finally {
...
void fileWrite(String filePath, String data)
file Write
BufferedWriter out = null;
try {
 out = new BufferedWriter(new FileWriter(filePath));
 out.write(data);
} catch (IOException e) {
 e.printStackTrace();
} finally {
 out.close();
...
void fileWrite(String filePath, String fileName, String content)
file Write
if (filePath.endsWith("/")) {
 filePath = filePath.substring(0, filePath.length() - 1);
File dest = new File(filePath);
if (!dest.exists()) {
 dest.mkdirs();
try {
...
int fileWrite(String path, int format, String content, Object bytesObj)
file Write
byte[] bytes = null;
try {
 switch (format) {
 case 0:
 bytes = (byte[]) bytesObj;
 break;
 case 1: 
 bytes = content.getBytes("UTF-8");
...
boolean fileWrite(String[] text, File file)
Writes an array of String to specified text file.
try {
 BufferedWriter out = new BufferedWriter(new FileWriter(file));
 PrintWriter writeOut = new PrintWriter(out);
 for (int i = 0; i < text.length; i++) {
 writeOut.println(text[i]);
 writeOut.close();
 return true;
...
long fileWriteOut(InputStream in, String outPath)
file Write Out
byte[] buf = new byte[1024];
int length = 0;
long fileSize = 0;
OutputStream out = null;
try {
 out = new BufferedOutputStream(new FileOutputStream(outPath));
 while ((length = in.read(buf)) > 0) {
 fileSize += length;
...
void fileWriter(int startpt, int letter)
file Writer
System.out.println("Start point: " + (char) startpt);
System.out.println("End point: " + (char) 55203);
String filename = (char) letter + "";
System.out.println("Writing to file: " + filename);
ArrayList letters = lastLetterGen(startpt);
try {
 PrintWriter pr = new PrintWriter(filename);
 for (int i = 0; i < letters.size(); i++) {
...
void fileWriter(String outfile, String contents, boolean append)
Synopsis [ ] String to file, with append to file true/false option
try {
 BufferedWriter bw = new BufferedWriter(new FileWriter(new File(outfile), append)); 
 bw.write(contents);
 bw.close();
} catch (Exception e) {
void fileWriteString(String filePath, String strWrite, boolean append)
file Write String
File f = new File(filePath);
Writer out = null;
try {
 out = new FileWriter(f, append);
 out.write(strWrite);
 out.close();
} catch (IOException e) {
 e.printStackTrace();
...


AltStyle によって変換されたページ (->オリジナル) /