Categories:
Audio (13)
Biotech (29)
Bytecode (22)
Database (79)
Framework (7)
Game (7)
General (497)
Graphics (53)
I/O (32)
IDE (2)
JAR Tools (70)
JavaBeans (16)
JDBC (86)
JDK (338)
JSP (20)
Logging (90)
Mail (54)
Messaging (8)
Network (106)
PDF (82)
Report (7)
Scripting (75)
Security (67)
Server (112)
Servlet (17)
SOAP (24)
Testing (55)
Web (24)
XML (287)
Other Resources:
Test Program on java.activation.DataSource
How to write a simple test program on java.activation.DataSource? I want to try the JAF (JavaBeans Activation Framework) included in JDK.
✍: FYIcenter.com
JAF (JavaBeans Activation Framework) API 1.1 has been included in JDK since 1.6. You use the following simple test program, DataSourceTest.java, to try it:
// Copyright (c) 2015 FYIcenter.com import javax.activation.*; public class DataSourceTest { public static void main(String[] args) throws Exception { String filename = args[0]; DataSource ds = new FileDataSource(filename); System.out.println("getName() = "+ds.getName() ); System.out.println("getContentType() = " +ds.getContentType() ); } }
Compile and run with only JDK and no activation.jar:
\fyicenter>java -version java version "1.7.0_45" \fyicenter>javac -classpath . DataSourceTest.java \fyicenter>java -classpath . DataSourceTest getName() = DataSourceTest.java getContentType() = application/octet-stream
The above session shows that my JAF configuration does not recognize *.java files as text files. Here is how to change the JAF configuration:
Edit .mime.types in my home folder c:\users\fyicenter and add the following line. Then run the test program again:
\fyicenter>edit c:\users\fyicenter\.mime.types text/plain txt text TXT TEXT java \fyicenter>java -classpath . DataSourceTest getName() = DataSourceTest.java getContentType() = text/plain
Note that the .mime.types file defines mapping of a MIME types with file extensions with a tab character.
2016-07-09, 2060👍, 0💬
Popular Posts:
JDK 11 jdk.jfr.jmod is the JMOD file for JDK 11 JFR module. JDK 11 JFR module compiled class files a...
The JSR 105 XML Digital Signature 1.0.1 FCS implementation provides an API and implementation that a...
JasperReports, the world's most popular open source business intelligence and reporting engine and J...
What Is mail.jar of JavaMail 1.4.2? I got the JAR file from javamail-1.4.2.zip. mail.jar in javamail...
JDK 11 jdk.hotspot.agent.jmod is the JMOD file for JDK 11 Hotspot Agent module. JDK 11 Hotspot Agent...