±Û¾´ÀÌ :candy 1998³â 1¿ù 21ÀÏ 14:01:27
Á¦°¡ ÇϰíÀÚ ÇÏ´Â ÀÏÀº ƯÁ¤ ÈÀÏÀÇ ³»¿ëÀ» ÀÐ¾î¼ textarea¿¡ ±× ³»¿ëÀ» º¸¿©ÁÖ°í editÀÛ¾÷À» ÇÑ ÈÄ ÀúÀå ¹öưÀ» ´©¸£¸é ±× ³»¿ëÀÌ ÀúÀåµÇ±â¸¦ ¿øÇÕ´Ï´Ù. Àд µ¥¼´Â ¹®Á¦°¡ ¾ø¾ú´Âµ¥ ÈÀÏ¿¡ ±× ³»¿ëÀ» ¾²´Âµ¥ ¹®Á¦°¡ ÀÖ½À´Ï´Ù.
¹è¿îÁö ¾ó¸¶µÇÁö ¾Ê¾Æ¼ ÇÁ·Î±×·¥ÀÌ ±ò²ûÇÏÁö¸¦ ¸øÇÕ´Ï´Ù. ¾Æ½Ã´Â ºÐÀº Àú¿¡°Ô µµ¿òÀ» Á».....
µ¡ºÙ¿© ¹°¾îº¸¸é ¿©·¯°³°¡ ÀÖ´Â InputStreamÀ» °¢°¢ ¾îµð¼ ½á¾ßÇÒ Áö È®½ÇÈ÷ ±¸ºÐÀÌ µÇÁö ¾Ê½À´Ï´Ù.
ÁÁÀº °ÀǸ¦ ±â´Ù¸®¸é¼.....
<¿¹Á¦>
import java.awt.*;
import java.io.*;
import java.awt.event.*;
public class DisplayFile {
FileInputStream fi;
FileOutputStream fo;
File myFile;
String FileName;
TextArea ta;
Frame f;
Button bok;
public static void main(String args[]) {
DisplayFile Df = new DisplayFile(args[0]);
Df.init();
}
public DisplayFile(String temp) {
FileName = temp;
f = new Frame();
}
public void init() {
myFile = new File(FileName);
byte b[] = new byte[(int) myFile.length()];
try {
fi = new FileInputStream(myFile);
} catch (FileNotFoundException e) {
System.out.println(" file not found");
}
try {
fi.read(b);
} catch (IOException e1) {
System.out.println("IO Error");
}
String s = new String(b);
ta = new TextArea(s , 20 , 50);
bok = new Button("SAVE");
bok.addActionListener(new ButtonHandler());
f.add(ta , "Center");
f.add(bok , "North");
f.setSize(100,100);
f.setVisible(true);
f.addWindowListener (new WindowHandler());
}
private class WindowHandler extends WindowAdapter {
public void windowClosing (WindowEvent e4) {
f.setVisible(false);
f.dispose();
System.exit(0);
}
}
private class ButtonHandler implements ActionListener {
public void actionPerformed(ActionEvent e5) {
String imsi;
imsi = ta.getText();
byte b1[] = new byte[(int) imsi.length()];
try {
fo = new FileOutputStream("ko.txt");
} catch (FileNotFoundException e) {
System.out.println(" file not found");
} catch (IOException ee) {
System.out.println("IO ERROR");
}
try {
fo.write(b1);
} catch (IOException e1) {
System.out.println("IO Error");
}
}
}
}