TAILIEUCHUNG - programming XML by Example phần 10

Viết lại một tập tin văn bản với kết thúc của dòng hệ thống cụ thể - hữu ích cho các tập tin văn bản tải về từ trình * vao hai tên tập tin trên dòng lệnh: đầu vào và đầu cơ sở dữ liệu được sử dụng rộng rãi nhất và có thể tích hợp dữ liệu từ nhiều cơ sở dữ liệu trong một báo cáo. Crystal Reports đã được xác nhận là | 462 Appendix A I Listing is a Java application that converts a text file to your platform end-of-line convention. Listing Java Application EXAMPLE package import . Rewrite a text file with system-specific end of lines. BR Useful for text files downloaded from the Net. @author Benoit Marchal Aversion 28 August 1999 public class LeL Entry-point for the program. BR Expect two filenames on the command-line input and output. @param args command-line parameters public static void main String args if 2 Usage is java input output we don t want to overwrite a file by mistake else if new File args 1 .exists Error output file already exists else try BufferedReader reader new BufferedReader new FileReader args 0 Printwriter writer new Printwriter new Filewriter args 1 Appendix A 463 the try finally guarantees the writer is closed try for String line null line line line finally catch IOException e Error 11 UNIX uses an LF character to signal end of lines the Mac uses the CR character and Windows uses a combination of CR LF. Needless to say text files such as XML documents saved on one platform are not easy to manipulate on another platform. This application rewrites the file to your platform convention. You must save this program in a file called . Java is picky about filenames. To compile issue this command javac -d . CAUTION This assumes the Java compiler is in your path. If not you will have to prefix the javac command with the path to the compiler as in c java javac -d . OUTPUT You can run it with java Figures and illustrate how the LeL program reorganizes the file. Notice that in Figure the lines are all wrong. 464 Appendix A Figure A UNIX file under Windows Figure The same file after LeL rewrote it

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.