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, 2063👍, 0💬
Popular Posts:
ZooKeeper is a centralized service for maintaining configuration information, naming, providing dist...
JRE 8 rt.jar is the JAR file for JRE 8 RT (Runtime) libraries. JRE (Java Runtime) 8 is the runtime e...
Apache Axis2 is the core engine for Web services. It is a complete re-design and re-write of the wid...
JDK 11 jdk.charsets.jmod is the JMOD file for JDK 11 Charsets module. JDK 11 Charsets module compile...
The JGoodies Forms framework helps you lay out and implement elegant Swing panels consistently and q...