¥È¥Ã¥×   ¿·µ¬ °ìÍ÷ ñ¸ì¸¡º÷ ºÇ½ª¹¹¿·   ¥Ø¥ë¥×   ºÇ½ª¹¹¿·¤ÎRSS

java/¥Õ¥¡¥¤¥ëÆþ½ÐÎÏ ¤Î¥Ð¥Ã¥¯¥¢¥Ã¥×(No.1)


java

¥Æ¥­¥¹¥È¥Õ¥¡¥¤¥ëÆɤ߹þ¤ß

import java.io.*;

try {
	FileReader fr = new FileReader("¥Õ¥¡¥¤¥ë̾");
	int c;
	String str = new String();
	while ((c = fr.read()) != -1) {
		str = str + (char)c;
	}
	fr.close();
} catch (IOException e) {
	System.err.println(e);
}

¥Æ¥­¥¹¥È¥Õ¥¡¥¤¥ë½ñ¤­¹þ¤ß

import java.io.*;

try {
	FileWriter fw = new FileWriter("¥Õ¥¡¥¤¥ë̾");
	fw.write("½ñ¤­¹þ¤ß¤¿¤¤Ê¸»úÎó");
	fw.close();
} catch (IOException e) {
	System.err.println(e);
}

¥Ð¥Ã¥Õ¥¡ÉÕ¤­¥Æ¥­¥¹¥È¥Õ¥¡¥¤¥ëÆɤ߹þ¤ß

import java.io.*;

try {
	FileReader fr = new FileReader("¥Õ¥¡¥¤¥ë̾");
	BufferedReader br = new BufferedReader(fr);

	String str = new String();
	while ((str = br.readLine()) != null) {
		System.out.println(str); // ½èÍý¤òµ­½Ò
	}
	br.close();
} catch (IOException e) {
	System.err.println(e);
}

¥Ð¥Ã¥Õ¥¡ÉÕ¤­¥Æ¥­¥¹¥È¥Õ¥¡¥¤¥ë½ñ¤­¹þ¤ß

import java.io.*;

try {
	FileWriter fw = new FileWriter("¥Õ¥¡¥¤¥ë̾");
	BufferedWriter fr = new BufferedWriter(fw);

	bw.write(½ñ¤­¹þ¤ß¤¿¤¤¥Ç¡¼¥¿);
	bw.newLine; // ¹Ô¶èÀÚ¤ê
	bw.flush;
	bw.close();
} catch (IOException e) {
	System.err.println(e);
}

¥Ð¥¤¥Ê¥ê¥Õ¥¡¥¤¥ë byteñ°Ì¤ÎÆɤ߹þ¤ß

import java.io.*;

try {
	FileInputStream fis = new FileInputStream("¥Õ¥¡¥¤¥ë̾");
	int b;
	while ((b = fis.read()) != -1) {
		System.out.println(b); // ½èÍý¤òµ­½Ò
	}
	fis.close();
} catch (FileNotFoundException e) {
	System.err.println(e);
} catch (IOException e) {
	System.err.println(e);
}

¥Ð¥¤¥Ê¥ê¥Õ¥¡¥¤¥ë byteñ°Ì¤Î½ñ¤­¹þ¤ß

import java.io.*;

try {
	FileOutputStream fos = new FileOutputStream("¥Õ¥¡¥¤¥ë̾");
	fos.write(½ñ¤­¹þ¤ß¤¿¤¤¥Ç¡¼¥¿);
	fos.close();
} catch (FileNotFoundException e) {
	System.err.println(e);
} catch (IOException e) {
	System.err.println(e);
}

¥Ð¥¤¥Ê¥ê¥Õ¥¡¥¤¥ë³Æ¼ï¥Ç¡¼¥¿Æɤ߹þ¤ß

import java.io.*;

try {
	FileInputStream fis = new FileInputStream("¥Õ¥¡¥¤¥ë̾");
	DataInputStream dis = new DataInputStream(fis);
	int i = dis.readInt();
	String str = dis.readUTF();
	dis.close();
} catch (FileNotFoundException e) {
	System.err.println(e);
} catch (IOException e) {
	System.err.println(e);
}

¥Ð¥¤¥Ê¥ê¥Õ¥¡¥¤¥ë³Æ¼ï¥Ç¡¼¥¿½ñ¤­¹þ¤ß

import java.io.*;

try {
	FileOutputStream fos = new FileOutputStream("¥Õ¥¡¥¤¥ë̾");
	DataOutputStream dos = new DataOutputStream(fos);
	dos.writeInt(½ñ¤­¹þ¤ß¤¿¤¤int·¿¥Ç¡¼¥¿);
	dos.writeUTF(½ñ¤­¹þ¤ß¤¿¤¤Ê¸»úÎó¥Ç¡¼¥¿);
	dos.close();
} catch (FileNotFoundException e) {
	System.err.println(e);
} catch (IOException e) {
	System.err.println(e);
}