📄 readme
字号:
Java Web Start Random Access File Demo--------------------------------------Brief Description :This sample demonstrates features of JNLPRandomAccessFile API.The file which user picks is opened as a random file for both Writing and Reading. Application first writes some hard coded strings to the file selected by the user. It then reads whatever was written to the file and displays it on to the screen using awt Containter and the TextArea components. The following JNLP API is used by the Application : FileOpenService : openFileDialog will allow the user to choose a single file. Contents of the selected file is returned as a FileContents object.FileContents : This object encapsulates the name and contents of a file. getLength(), getMaxLength() and setMaxLength are used. If thethe maximum file size defined by the client is not more than 1024bytes of the current length, then it will be adjusted accordingly. getName() returns the name of the file selected.getRandomAccessFile() method is used for creating JNLPRandomAccessFile with read/write permissions.JNLPRandomAccessFile : Methods provided by this interface are usedfor reading and writing to random file. seek() sets the file-pointeroffset, measured from the beginning of this file, at which the nextread or write occurs. writeUTF() and writeBytes() are demonstratedfor writing to a file. readLine() is used for reading the next linefrom the file.Java Web Start is launched automatically by browser when the user clicks ona link which is associated with JNLP file. It then downloads and caches theRAFSample application on the local client machine where browser is running.This cached application when invoked next time is already downloaded andruns as fast as a traditionally installed application.By default applicationsare run in a protective environment (sandbox) with restricted access tolocal disk and network resources. Java Web Start only transfers JAR files from the Web server to the location determined by it on the client machine. To provide a simple and convenient packaging format of Applications, JavaWeb Start includes a servlet in the developer's pack. The name of the servletis JnlpDownloadServlet and is packaged into the jnlp-servlet.jar file. Thisservlet eases deployment of application on any J2EE-complaint applicationserver by packing a JNLP files and its associated resources in a Web Archive(.war) file. For more details on Java Web Start product and JNLP API, Please check outonline docs athttp://java.sun.com/products/javawebstart/developers.htmlFiles :src - This directory has all the required source files : randomFile.javalib - This directory contains the jar files generated after the build process.class - This directory containing .class files is generated by the build process.war - This directory contains all the files required for deploying a web based application. Application related .jnlp files and .jar files are inside app.Building & Deployment of Application :1) Build .class and .jar files by running gnumake in the directory where GNUmakefile file resides. The following environment variable must be set: # environment variable CLASS_PATH should contain path to javaws.jar # environment variable SDK_HOME should point to SDK directory If you are running on windows platform, it also assume you have MKS Toolkit installed and it is in your path environment variable. (We need commands like cp, echo, mkdir, rm) The generated classes will go to the classes directory, and the resulting jar files will be in the lib directory by default. You can adjust the output directory to anything you want by changing the GNUmakefile.2) To ease the deployment of application to on any J2EE-complaint server all the resources required including .jnlp and jar files are packed into a Web Archive (.war) file. Please put the following files into the war directory: war/WEB-INF/lib/jnlp-servlet.jar (from building the JNLPDownloadServlet) war/WEB-INF/lib/<jar files for XML parser> (not needed if servlet container is running J2SE 1.4+; or if the servlet container already comes with a XML parser in it) war/app/randomFile.jar (generated in the lib directory) To build .war file, run below command inside the war directory jar -cvf ../RAFSample.war .3) Copy RAFSample.war file generated to the your web server directory. For Tomcat server, copy RAFSample.war file to $TOMCAT_HOME/webapps directory and restart the web server.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -