TAILIEUCHUNG - Java 6 Platform Revealed phần 2

Tham khảo tài liệu 'java 6 platform revealed phần 2', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | 6 CHAPTER 1 JAVA SE 6 AT A GLANCE As soon as a hit is found for your mime type searching stops. Note See the javadoc for the MailcapCommandMap class for information on the format of the .mailcap file. Another thing you can do with the Activation Framework is map files to mime types. This is something your e-mail client typically does to see if it knows how to handle a particular attachment. The program in Listing 1-2 displays the mime types that it thinks are associated with the files in a directory identified from the command line. Listing 1-2. Getting the File Type Map import . import . public class FileTypes public static void main String args FileTypeMap map String path if 0 path . else path args 0 File dir new File path File files for File file files file The default implementation of the FileTypeMap class is its MimetypesFileTypeMap subclass. This does a mapping of file extensions to mime types. Theoretically you could create your own subclass that examined the first few bytes of a file for its magic signature for instance 0XCAFEBABE for .class files . The output from running the program is dependent on the directory you run it against. With no command-line argument the current directory is used as the source CHAPTER 1 JAVA SE 6 AT A GLANCE 7 java FileTypes tmp image jpeg text html image gif audio x-wav text plain image tiff With the JavaMail API you would typically create a DataHandler for the part of the multipart message associating the content with the mime type String text . DataHandler handler new DataHandler text text plain BodyPart part new MimeBodyPart handler Under the covers this would use the previously mentioned maps. If the system didn t know about the mapping of file extension to mime type you would have to add it to the map allowing the

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.