자바 소스 분석좀도와주세요
파랑
자바 에디터에 한부분 코드입니다.
부탁드립니다.
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;
}
-
핑크빛애교
코드 해석은 최대한 해보시고 모르는 부분을 물어보세요~
| 번호 | 제 목 | 글쓴이 | 날짜 |
|---|---|---|---|
| 2752135 | [질문]칼라피커 콘트롤에 특정칼라를 선택된상태로만들려면 어떻게하면되나여? | 널위해 | 2026-10-21 |
| 2752110 | $box.find("img").width()에서 이미지에.. | 해뜰참 | 2026-10-21 |
| 2752024 | 소숫점 뺄셈 !! ㅠㅜ | 초롬 | 2026-10-20 |
| 2751970 | 자바 게임 만들려는데 부탁드립니다 (1) | 라온제나 | 2026-10-19 |
| 2751908 | 자바스크립트 처리속도를 체크할 수 있는 방법 있나요? (1) | 테이 | 2026-10-19 |
| 2751822 | 그누보드 아이프레임으로 구현했는데 제목 클릭해서 들어가면 푸터가 동동...떠다녀요 | 내꺼하자 | 2026-10-18 |
| 2751790 | 자바 그래픽 관련을 공부하고 싶은데요.. 어디 좋은 사이트나 책 없을까요?? (1) | 큰재 | 2026-10-18 |
| 2751733 | CTF가머죠? (5) | 두동 | 2026-10-17 |
| 2751709 | 배열부분 궁금한 부분이있습니다. | 딸기우유 | 2026-10-17 |
| 2751677 | 포인터 책을 보다가,,, (2) | 동백 | 2026-10-17 |
| 2751648 | 익스플로 버전에 따라서 생기는 공백.. (1) | 모아 | 2026-10-17 |
| 2751623 | DEL 태그의에서 선굵기 및 컬러지정이 가능한가 해서요~ (4) | 비치나 | 2026-10-16 |
| 2751573 | 테마 업로드 에러.. (1) | 꽃 | 2026-10-16 |
| 2751548 | 수학? 물리?? (3) | 찬늘 | 2026-10-16 |
| 2751461 | 상단네비 fixed ie6 핵 해결방안이 있을까요? | 맑다 | 2026-10-15 |
| 2751436 | 레이아웃을 잡고 코딩을 하는데 드림위버에서의 결과와 IE에서 결과가 다르게 나오네요. (3) | 키클 | 2026-10-15 |
| 2751403 | 형들좀도와주세요string compression (1) | 알렉산더 | 2026-10-14 |
| 2751349 | 링크 다운로드하기 | 팬지 | 2026-10-14 |
| 2751267 | 플래시8 사용에서 플레이어 만들었는데요 (1) | 블1랙캣 | 2026-10-13 |
| 2751182 | 회원가입 | 파랑새 | 2026-10-12 |
