String fileName = "text.txt";
FileOutputStream fos = new FileOutputStream(fileName);
fos.write('a');
fos.write("abc".getBytes());
fos.close();
String fileName = "text.txt";
FileInputStream fis = new FileInputStream(fileName);
int read;
byte[] bytes = new byte[1024];
while ((read = fis.read()) == -1) {
System.out.println((char) read);
}
while ((read = fis.read()) == -1) {
System.out.println(new String(bytes, 0, read));
}
fis.close();
String fileName = "text.txt";
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(fileName));
bos.write('a');
bos.write("abcd".getBytes());
bos.flush();
bos.close();
String fileName = "text.txt";
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(fileName));
int read = 0;
byte[] bytes = new byte[1024];
while ((read = bis.read()) != -1) {
System.out.println((char)read);
}
while ((read = bis.read(bytes)) != -1) {
System.out.println(new String(bytes, 0, read));
}
bis.close();
String fileName = "text.txt";
OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream(fileName));
osw.write('a');
osw.write("abc");
osw.flush();
osw.close();
String fileName = "text.txt";
InputStreamReader isr = new InputStreamReader(new FileInputStream(fileName));
int read;
char[] chars = new char[1024];
while ((read = isr.read()) != -1) {
System.out.println((char)read);
}
while ((read = isr.read(chars)) != -1) {
System.out.println(new String(chars, 0, read));
}
isr.close();
String fileName = "text.txt";
FileWriter fw = new FileWriter(fileName);
fw.write('a');
fw.write("abc");
fw.flush();
fw.close();
String fileName = "text.txt";
FileReader fr = new FileReader(fileName);
int read = 0;
char[] chars = new char[1024];
while ((read = fr.read()) != -1) {
System.out.println((char) read);
}
while ((read = fr.read(chars)) != -1) {
System.out.println(new String(chars, 0, read));
}
fr.close();
String fileName = "text.txt";
BufferedWriter bw = new BufferedWriter(new FileWriter(fileName));
bw.write('a');
bw.write("abc");
bw.newLine();
bw.flush();
bw.close();
String fileName = "text.txt";
BufferedReader br = new BufferedReader(new FileReader(fileName));
int read = 0;
char[] chars = new char[1024];
String line = "";
while ((read = br.read()) != -1) {
System.out.print(read);
}
while ((read = br.read(chars)) != -1) {
System.out.print(new String(chars, 0, read));
}
while ((line = br.readLine()) != null) {
System.out.println(line);
}
br.close();