Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- 고려대학원
- 리버싱엔지니어링
- http://reversing.kr/
- 레가
- forensic
- e-discovery
- 레지스트리포렌식
- x64dbg
- 엔케이스
- 디지털포렌식
- U's room
- Opentext
- 사이버수사
- 서호전
- 사이버수사과
- 역연산
- Reversing
- KDFS2022 #KDFS2023 #학생트랙 #멤버모집 #포공학 #포렌식 #디지털포렌식 #범인을찾아라 #DFC #포렌식대회 #보고서 #학생트랙보고서
- 포렌식 #안티포렌식 #레지스트리 #거부권한 #깃허브 #Forensics #forensic #anti-forensic #anti-forenscis #컴퓨터 #사이버수사 #수사관 #KDFS
- 이디스커버리
- 악성코드 분석
- 포렌식
- encase
- 리버싱
- REGA
- 서울호서직업전문학교
- 악성코드
- Music_Player
- 악성코드분석
- reversing.kr
Archives
- Today
- Total
DDDDigtal 4ensics
[Java] 메모장 만들기 본문
package notepad;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.UIManager;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JButton;
import javax.swing.JFileChooser;
public class main_form {
private JFrame frmNotepad;
private String filepath = null;
private JTextArea textArea;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
main_form window = new main_form();
window.frmNotepad.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the application.
*/
public main_form() {
initialize();
}
/**
* Initialize the contents of the frame.
*/
private void initialize() {
frmNotepad = new JFrame();
frmNotepad.setTitle("null - notepad");
frmNotepad.setBounds(100, 100, 800, 600);
frmNotepad.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JScrollPane scrollPane = new JScrollPane();
GroupLayout groupLayout = new GroupLayout(frmNotepad.getContentPane());
groupLayout.setHorizontalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addComponent(scrollPane, GroupLayout.DEFAULT_SIZE, 784, Short.MAX_VALUE)
);
groupLayout.setVerticalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addComponent(scrollPane, GroupLayout.DEFAULT_SIZE, 561, Short.MAX_VALUE)
);
textArea = new JTextArea();
scrollPane.setViewportView(textArea);
frmNotepad.getContentPane().setLayout(groupLayout);
JMenuBar menuBar = new JMenuBar();
frmNotepad.setJMenuBar(menuBar);
JMenu fileM = new JMenu("파일");
JMenu editM = new JMenu("편집");
menuBar.add(fileM);
menuBar.add(editM);
JMenuItem save = new JMenuItem("저장");
JMenuItem save_as = new JMenuItem("다른 이름으로 저장");
JMenuItem open = new JMenuItem("열기");
JMenuItem exit = new JMenuItem("저장하지 않고 닫기");
fileM.add(save);
fileM.add(save_as);
fileM.addSeparator();
fileM.add(open);
fileM.addSeparator();
fileM.add(exit);
save.addActionListener(new MenuActionListener());
save_as.addActionListener(new MenuActionListener());
open.addActionListener(new MenuActionListener());
exit.addActionListener(new MenuActionListener());
}
class MenuActionListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
String cmd = e.getActionCommand();
switch(cmd) {
case "저장" :
if(filepath == null) {
try {
JFileChooser jfc = new JFileChooser();
int returnVal = jfc.showSaveDialog(null);
if(returnVal == 0) {
filepath = jfc.getSelectedFile().toString();
}
File fi = new File(filepath);
frmNotepad.setTitle(fi.getName() + " - notepad");
BufferedOutputStream bs = new BufferedOutputStream(new FileOutputStream(filepath));
String str = textArea.getText();
bs.write(str.getBytes());
bs.close();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (NullPointerException e1) {
}
} else {
try {
BufferedOutputStream bs = new BufferedOutputStream(new FileOutputStream(filepath));
String str = textArea.getText();
bs.write(str.getBytes());
bs.close();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
break;
case "열기" :
String strs = "";
textArea.setText(strs);
try {
JFileChooser jfc = new JFileChooser();
int returnVal = jfc.showSaveDialog(null);
if(returnVal == 0) {
filepath = jfc.getSelectedFile().toString();
}
BufferedReader br = new BufferedReader(new FileReader(filepath));
String str;
File fi = new File(filepath);
frmNotepad.setTitle(fi.getName() + " - notepad");
while((str = br.readLine()) != null) {
textArea.append(str + System.lineSeparator());
}
br.close();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
}
}
그냥 친구가 만들어달래서 만들어봄
열기 저장 밖에 안만듬. 나라면 글꼴 변경, 다른 이름으로 저장 등등 다양한 기능을 더 만들 수 있을 듯 틀만 잡아달라고 부탁했으니 이정도만 함.
저장도 잘되고 비록 txt파일은 아니지만 열기도 잘 됨 한자도 잘 출력된다.
귀찮지만 마지막 테스트