Đang chuẩn bị liên kết để tải về tài liệu:
programming XML by Example phần 10

Không đóng trình duyệt đến khi xuất hiện nút TẢI XUỐNG

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ừ Net.chương trình * vao hai tên tập tin trên dòng lệnh: đầu vào và đầu ra.từ 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 A.1 is a Java application that converts a text file to your platform end-of-line convention. Listing A.1 Java Application EXAMPLE package com.psol.lel import java.io. 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 args.length 2 System.err.println Usage is java com.psol.lel.LeL input output we don t want to overwrite a file by mistake else if new File args 1 .exists System.err.println 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 reader.readLine null line line reader.readLine writer.println line finally writer.close catch IOException e System.err.println Error 11 e.getMessage 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 LeL.java. Java is picky about filenames. To compile issue this command javac -d . LeL.java 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 . LeL.java OUTPUT You can run it with java com.psol.lel.LeL unixfile.txt windowsfile.txt Figures A.1 and A.2 illustrate how the LeL program reorganizes the file. Notice that in Figure A.1 the lines are all wrong. 464 Appendix A Figure A.1 A UNIX file under Windows Figure A.2 The same file after LeL rewrote it

Đã 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.