자바 소스 분석좀도와주세요
파랑
자바 에디터에 한부분 코드입니다.
부탁드립니다.
public class DocumentEditorApp extends SingleFrameApplication {
@Override protected void startup() {
show(new DocumentEditorView(this));
}
}
public static DocumentEditorApp getApplication() {
return Application.getInstance(DocumentEditorApp.class);
}
public static void main(String[] args) {
launch(DocumentEditorApp.class, args);
}
static class SaveTextFileTask extends TaskVoid, Void {
private final File file;
private final String text;
SaveTextFileTask(Application app, File file, String text) {
super(app);
this.file = file;
this.text = text;
}
public final File getFile() {
return file;
}
public final String getText() {
return text;
}
private void renameFile(File oldFile, File newFile) throws IOException {
if (!oldFile.renameTo(newFile)) {
String fmt = file rename failed: %s = %s;
throw new IOException(String.format(fmt, oldFile, newFile));
}
}
protected Void doInBackground() throws IOException {
String absPath = file.getAbsolutePath();
File tmpFile = new File(absPath + .tmp);
tmpFile.createNewFile();
tmpFile.deleteOnExit();
File backupFile = new File(absPath + .bak);
BufferedWriter out = null;
int fileLength = text.length();
int blockSize = Math.max(1024, 1 + ((fileLength - 1) / 100));
try {
out = new BufferedWriter(new FileWriter(tmpFile));
int offset = 0;
while (!isCancelled() && (offset fileLength)) {
int length = Math.min(blockSize, fileLength - offset);
out.write(text, offset, length);
offset += blockSize;
setProgress(Math.min(offset, fileLength), 0, fileLength);
}
} finally {
if (out != null) {
out.close();
}
}
if (!isCancelled()) {
backupFile.delete();
if (file.exists()) {
renameFile(file, backupFile);
}
renameFile(tmpFile, file);
} else {
tmpFile.delete();
}
return null;
}
-
핑크빛애교
코드 해석은 최대한 해보시고 모르는 부분을 물어보세요~
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2657034 | 질문이요..ㅠ (2) | 연보라 | 2024-06-03 |
2657009 | [질문]액션스크립트 책 좀 골라주세요.. (10) | 후유 | 2024-06-03 |
2656985 | c++ 순환함수 질문드립니다 ㅠㅠ (6) | 마루한 | 2024-06-02 |
2656960 | p, h 관계 (5) | 시내 | 2024-06-02 |
2656934 | window.print() 에대해서 질문좁할께요 | 주리 | 2024-06-02 |
2656904 | 풀더 경로 로 통해서 삭제하지말고 같은 풀더에잇는 파일 삭제하기. | 요루 | 2024-06-02 |
2656873 | 사진 엑박 질문입니다 | 달빛 | 2024-06-01 |
2656847 | 이런-ㅁ-;자바실행 (1) | 파라미 | 2024-06-01 |
2656823 | [질문]인터넷 익스플로어 관련... (3) | 자올 | 2024-06-01 |
2656792 | 다음 로그인소스 (2) | 보미 | 2024-06-01 |
2656736 | 다시한번 질문합니다. | 뽀야 | 2024-05-31 |
2656708 | IETester 도구를 사용해 보고있는데 결과가 다르게 나옵니다. (6) | 앵겨쪼 | 2024-05-31 |
2656653 | 버튼 누르면 이메일로 내용이 전송되게 하는 소스아시나요?ㅠㅠ | 허우룩 | 2024-05-30 |
2656575 | 굵기 하는법 | 빵야 | 2024-05-30 |
2656525 | vb2008에서 6.0으로 변환중에 이런오류가 나네요...왜이런지; (1) | 비사벌 | 2024-05-29 |
2656466 | 맥북의 장점이 무엇인가요? (4) | 티나 | 2024-05-29 |
2656436 | [제작의뢰]간단한 자바 프로그램. (1) | 참이 | 2024-05-28 |
2656408 | 자바 객체 생성에 관한 질문입니다. | 해비치 | 2024-05-28 |
2656382 | 혹시 맥북환경에서 test 하시는분 계신가요? (1) | 달달한캔디 | 2024-05-28 |
2656332 | 도움이 될까해서 글을올립니다(avada 테마관련) (1) | 계획자 | 2024-05-27 |