readme
来自「一个小公司要求给写的很简单的任务管理系统。」· 代码 · 共 113 行
TXT
113 行
Java Web Start Random Access File Demo--------------------------------------Brief Description :This sample demonstrates features of the JNLPRandomAccessFile API. The file which user picks is opened as a random file for both Writing and Reading.The 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 iton 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 the the maximum filesize defined by the client is not more than 1024 bytes of the current length,then it will be adjusted accordingly. getName() returns the name of the fileselected. getRandomAccessFile() method is used for creatingJNLPRandomAccessFile with read/write permissions.JNLPRandomAccessFile : Methods provided by this interface are used for readingand writing to random file. seek() sets the file-pointer offset, measured fromthe beginning of this file, at which the next read or write occurs. writeUTF()and writeBytes() are demonstrated for writing to a file. readLine() is used forreading the next line from the file.Java Web Start is launched automatically by the browser when the user clickson a 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 next invoked, is already downloaded and runsas fast as a traditionally installed application. By default applications arerun in a protective environment (sandbox) with restricted access to local diskand network resources. Java Web Start only transfers JAR files from the Webserver to the location determined by it on the client machine.To provide a simple and convenient packaging format for applications, Java WebStart includes a servlet as a sample in the SDK. The name of the servlet is JnlpDownloadServlet and is packaged into the jnlp-servlet.jar file (from the JNLPDownloadServlet sample under sample/jnlp/servlet directory in the SDK). This servlet eases deployment of application on any J2EE-complaint application server 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 at:http://java.sun.com/products/javawebstart/developers.htmlFiles :GNUmakefile - This is the makefile to build the raf sample.src - This directory contains the required source file: 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 the app directory.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 (under # jre/lib directory) # environment variable SDK_HOME should point to SDK directory If you are running on windows platform, it is assumed you have MKS Toolkit installed and it is in your path environment variable. (Such commands as cp, echo, mkdir and rm are required) 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, allthe resources required, including .jnlp and jar files, are packed into a WebArchive (.war) file. Please put the following files into the war directory: war/WEB-INF/lib/jnlp-servlet.jar (from the JNLPDownloadServlet sample under sample/jnlp/servlet directory) 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 the generated RAFSample.war file to your web server directory. ForTomcat server, copy RAFSample.war file to $TOMCAT_HOME/webapps directory andrestart the web server.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?