글쓴이 :윤지섭 1998년 1월 22일 15:35:40
In Reply to: 그런데요.... posted by candy on 1998년 1월 22일 12:17:41:
질문하신 내용을 정확히 이해 할수가 없습니다.
다시 한번 자세히 질문을 올려주신다면 제가 알고 있는 한도에서
성심껏 도움을 드리지요.
님께서 올리신 소스를 제 멋대로 조금 수정해 봤습니다.
참고 하세요.
import java.io.*;
import java.awt.event.*;
public class DisplayFile extends Frame implements ActionListener,
WindowListener{
FileInputStream rf;
FileOutputStream wf;
File myFile;
TextArea ta;
public static void main(String args[]) {
DisplayFile Df = new DisplayFile(args[0]);
Df.addWindowListener(Df);
}
public DisplayFile(String temp) {
ta = new TextArea(20 , 50);
add(ta , "Center");
Button bok = new Button("SAVE");
bok.addActionListener(this);
add(bok , "North");
setSize(100,100);
setVisible(true);
init(temp);
}
public void init(String temp){
myFile = new File(temp);
byte b[] = new byte[(int) myFile.length()];
try {
rf = new FileInputStream(myFile);
for(int i =0; i < (int)myFile.length(); i++)
b[i] = (byte)rf.read();
rf.close();
} catch (IOException e) { }
ta.append(new String(b));
}
public void windowClosing (WindowEvent e4) {
setVisible(false);
dispose();
System.exit(0);
}
public void actionPerformed(ActionEvent e5) {
String imsi;
imsi = ta.getText();
byte b1[] = imsi.getBytes();
try {
wf = new FileOutputStream("ko.txt");
for(int i = 0; i < b1.length; i++){
if(b1[i] == '\n') wf.write((int)'\r');
wf.write(b1, i, 1);
}
wf.close();
}
catch (IOException ee) {
System.out.println("IO ERROR");
}
}
public void windowActivated(WindowEvent we1){}
public void windowClosed(WindowEvent we2){}
public void windowDeactivated(WindowEvent we3){}
public void windowDeiconified(WindowEvent we4){}
public void windowIconified(WindowEvent we5){}
public void windowOpened(WindowEvent we6){}
}