commons-fileupload user guide

本文介绍了FileUpload的使用方法,包括其工作原理、请求解析、上传项处理等。在请求解析方面,有简单场景和可定制场景;处理上传项时,对普通表单字段和文件上传有不同处理方式。此外,还提到了与病毒扫描器的交互问题及解决办法。

Using FileUpload

FileUpload can be used in a number of different ways, depending upon the requirements of your application. In the simplest case, you will call a single method to parse the servlet request, and then process the list of items as they apply to your application. At the other end of the scale, you might decide to customize FileUpload to take full control of the way in which individual items are stored; for example, you might decide to stream the content into a database.

Here, we will describe the basic principles of FileUpload, and illustrate some of the simpler - and most common - usage patterns. Customization of FileUpload is described elsewhere .

How it works

A file upload request comprises an ordered list of items that are encoded according to RFC 1867 , "Form-based File Upload in HTML". FileUpload can parse such a request and provide your application with a list of the individual uploaded items. Each such item implements the FileItem interface, regardless of its underlying implementation.

Each file item has a number of properties that might be of interest for your application. For example, every item has a name and a content type, and can provide an InputStream to access its data. On the other hand, you may need to process items differently, depending upon whether the item is a regular form field - that is, the data came from an ordinary text box or similar HTML field - or an uploaded file. The FileItem interface provides the methods to make such a determination, and to access the data in the most appropriate manner.

FileUpload creates new file items using a FileItemFactory. This is what gives FileUpload most of its flexibility. The factory has ultimate control over how each item is created. The default factory stores the item's data in memory or on disk, depending on the size of the item (i.e. bytes of data). However, this behavior can be customized to suit your application.

Parsing the request

Before you can work with the uploaded items, of course, you need to parse the request itself. Ensuring that the request is actually a file upload request is straightforward, but FileUpload makes it simplicity itself, by providing a static method to do just that.

// Check that we have a file upload request
boolean isMultipart = FileUpload.isMultipartContent(request);

Now we are ready to parse the request into its constituent items.

The simplest case

The simplest usage scenario is the following:

  • Uploaded items should be retained in memory as long as they are reasonably small.
  • Larger items should be written to a temporary file on disk.
  • Very large upload requests should not be permitted.
  • The built-in defaults for the maximum size of an item to be retained in memory, the maximum permitted size of an upload request, and the location of temporary files are acceptable.

Handling a request in this scenario couldn't be much simpler:

// Create a new file upload handler
DiskFileUpload upload = new DiskFileUpload();

// Parse the request
List /* FileItem */ items = upload.parseRequest(request);

That's all that's needed. Really!

The result of the parse is a List of file items, each of which implements the FileItem interface. Processing these items is discussed below.

Exercising more control

If your usage scenario is close to the simplest case, described above, but you need a little more control over the size thresholds or the location of temporary files, you can customize the behavior using the methods of the DiskFileUpload class, like this:

// Create a new file upload handler
DiskFileUpload upload = new DiskFileUpload();

// Set upload parameters
upload.setSizeThreshold(yourMaxMemorySize);
upload.setSizeMax(yourMaxRequestSize);
upload.setRepositoryPath(yourTempDirectory);

// Parse the request
List /* FileItem */ items = upload.parseRequest(request);

Of course, each of the configuration methods is independent of the others, but if you want to configure them all at once, you can do that with an alternate parseRequest() method, like this:

// Create a new file upload handler
DiskFileUpload upload = new DiskFileUpload();

// Parse the request
List /* FileItem */ items = upload.parseRequest(request,
yourMaxMemorySize, yourMaxRequestSize, yourTempDirectory);

Should you need further control over the parsing of the request, such as storing the items elsewhere - for example, in a database - you will need to look into customizing FileUpload.

Processing the uploaded items

Once the parse has completed, you will have a List of file items that you need to process. In most cases, you will want to handle file uploads differently from regular form fields, so you might process the list like this:

// Process the uploaded items
Iterator iter = items.iterator();
while (iter.hasNext()) {
FileItem item = (FileItem) iter.next();

if (item.isFormField()) {
processFormField(item);
} else {
processUploadedFile(item);
}
}

For a regular form field, you will most likely be interested only in the name of the item, and its String value. As you might expect, accessing these is very simple.

// Process a regular form field
if (item.isFormField()) {
String name = item.getFieldName();
String value = item.getString();
...
}

For a file upload, there are several different things you might want to know before you process the content. Here is an example of some of the methods you might be interested in.

// Process a file upload
if (!item.isFormField()) {
String fieldName = item.getFieldName();
String fileName = item.getName();
String contentType = item.getContentType();
boolean isInMemory = item.isInMemory();
long sizeInBytes = item.getSize();
...
}

With uploaded files, you generally will not want to access them via memory, unless they are small, or unless you have no other alternative. Rather, you will want to process the content as a stream, or write the entire file to its ultimate location. FileUpload provides simple means of accomplishing both of these.

// Process a file upload
if (writeToFile) {
File uploadedFile = new File(...);
item.write(uploadedFile);
} else {
InputStream uploadedStream = item.getInputStream();
...
uploadedStream.close();
}

Note that, in the default implementation of FileUpload, write() will attempt to rename the file to the specified destination, if the data is already in a temporary file. Actually copying the data is only done if the the rename fails, for some reason, or if the data was in memory.

If you do need to access the uploaded data in memory, you need simply call the get() method to obtain the data as an array of bytes.

// Process a file upload in memory
byte[] data = item.get();
...

Interaction with virus scanners

Virus scanners running on the same system as the web container can cause some unexpected behaviours for applications using FileUpload. This section describes some of the behaviours that you might encounter, and provides some ideas for how to handle them.

The default implementation of FileUpload will cause uploaded items above a certain size threshold to be written to disk. As soon as such a file is closed, any virus scanner on the system will wake up and inspect it, and potentially quarantine the file - that is, move it to a special location where it will not cause problems. This, of course, will be a surprise to the application developer, since the uploaded file item will no longer be available for processing. On the other hand, uploaded items below that same threshold will be held in memory, and therefore will not be seen by virus scanners. This allows for the possibility of a virus being retained in some form (although if it is ever written to disk, the virus scanner would locate and inspect it).

One commonly used solution is to set aside one directory on the system into which all uploaded files will be placed, and to configure the virus scanner to ignore that directory. This ensures that files will not be ripped out from under the application, but then leaves responsibility for virus scanning up to the application developer. Scanning the uploaded files for viruses can then be performed by an external process, which might move clean or cleaned files to an "approved" location, or by integrating a virus scanner within the application itself. The details of configuring an external process or integrating virus scanning into an application are outside the scope of this document.

What's next

Hopefully this page has provided you with a good idea of how to use FileUpload in your own applications. For more detail on the methods introduced here, as well as other available methods, you should refer to the JavaDocs .

The usage described here should satisfy a large majority of file upload needs. However, should you have more complex requirements, FileUpload should still be able to help you, with it's flexible customization capabilities.

[root@yfw ~]# cd /opt/openfire/enterprise/Spark-master [root@yfw Spark-master]# scp root@124.71.230.244:/opt/openfire/enterprise/Spark-master/spark-client.zip ./spark-client.zip The authenticity of host '124.71.230.244 (124.71.230.244)' can't be established. ECDSA key fingerprint is SHA256:U5XbNIctslcKEL1Lv354cOWi7Hsq2syxemRKcCOXqug. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added '124.71.230.244' (ECDSA) to the list of known hosts. spark-client.zip 100% 68MB 353.3MB/s 00:00 [root@yfw Spark-master]# unzip spark-client.zip -d spark-client-local Archive: spark-client.zip creating: spark-client-local/spark-client/distribution/ creating: spark-client-local/spark-client/distribution/resources/ creating: spark-client-local/spark-client/distribution/resources/sounds/ inflating: spark-client-local/spark-client/distribution/resources/sounds/presence_changed.wav inflating: spark-client-local/spark-client/distribution/resources/sounds/incoming.wav inflating: spark-client-local/spark-client/distribution/resources/sounds/outgoing.wav inflating: spark-client-local/spark-client/distribution/resources/sounds/bell.wav inflating: spark-client-local/spark-client/distribution/resources/sounds/chat_request.wav inflating: spark-client-local/spark-client/distribution/resources/systeminfo.dll inflating: spark-client-local/spark-client/distribution/resources/Info.plist inflating: spark-client-local/spark-client/distribution/resources/jniwrap.lic inflating: spark-client-local/spark-client/distribution/resources/startup.bat inflating: spark-client-local/spark-client/distribution/resources/jniwrap.dll inflating: spark-client-local/spark-client/distribution/resources/startup.sh creating: spark-client-local/spark-client/distribution/plugins/ inflating: spark-client-local/spark-client/distribution/plugins/growl.jar inflating: spark-client-local/spark-client/distribution/plugins/fileupload.jar inflating: spark-client-local/spark-client/distribution/plugins/roar.jar inflating: spark-client-local/spark-client/distribution/plugins/meet.jar inflating: spark-client-local/spark-client/distribution/plugins/tictactoe.jar inflating: spark-client-local/spark-client/distribution/plugins/fastpath.jar inflating: spark-client-local/spark-client/distribution/plugins/transferguard.jar inflating: spark-client-local/spark-client/distribution/plugins/translator.jar inflating: spark-client-local/spark-client/distribution/plugins/flashing.jar inflating: spark-client-local/spark-client/distribution/plugins/apple.jar inflating: spark-client-local/spark-client/distribution/plugins/spelling.jar inflating: spark-client-local/spark-client/distribution/plugins/reversi.jar creating: spark-client-local/spark-client/distribution/documentation/ inflating: spark-client-local/spark-client/distribution/documentation/ide-vscode-setup.html inflating: spark-client-local/spark-client/distribution/documentation/ide-intellij-setup.html creating: spark-client-local/spark-client/distribution/documentation/spark guide/ creating: spark-client-local/spark-client/distribution/documentation/spark guide/images/ extracting: spark-client-local/spark-client/distribution/documentation/spark guide/images/image021.png extracting: spark-client-local/spark-client/distribution/documentation/spark guide/images/image033.png inflating: spark-client-local/spark-client/distribution/documentation/spark guide/images/image015.png inflating: spark-client-local/spark-client/distribution/documentation/spark guide/images/image003.png inflating: spark-client-local/spark-client/distribution/documentation/spark guide/images/image027.png extracting: spark-client-local/spark-client/distribution/documentation/spark guide/images/image007.png extracting: spark-client-local/spark-client/distribution/documentation/spark guide/images/image001.png extracting: spark-client-local/spark-client/distribution/documentation/spark guide/images/image009.png inflating: spark-client-local/spark-client/distribution/documentation/spark guide/images/image031.png extracting: spark-client-local/spark-client/distribution/documentation/spark guide/images/image011.png inflating: spark-client-local/spark-client/distribution/documentation/spark guide/images/image025.png inflating: spark-client-local/spark-client/distribution/documentation/spark guide/images/image017.png inflating: spark-client-local/spark-client/distribution/documentation/spark guide/images/image029.png extracting: spark-client-local/spark-client/distribution/documentation/spark guide/images/image023.png inflating: spark-client-local/spark-client/distribution/documentation/spark guide/images/filelist.xml extracting: spark-client-local/spark-client/distribution/documentation/spark guide/images/image013.png extracting: spark-client-local/spark-client/distribution/documentation/spark guide/images/image005.png extracting: spark-client-local/spark-client/distribution/documentation/spark guide/images/image019.png inflating: spark-client-local/spark-client/distribution/documentation/spark guide/Spark.default.properties.guide.html inflating: spark-client-local/spark-client/distribution/documentation/spark.doap inflating: spark-client-local/spark-client/distribution/documentation/changelog.html inflating: spark-client-local/spark-client/distribution/documentation/sparkplug_compile.html creating: spark-client-local/spark-client/distribution/documentation/images/ inflating: spark-client-local/spark-client/distribution/documentation/images/IntelliJ-8.JPG inflating: spark-client-local/spark-client/distribution/documentation/images/VSCode-4.png inflating: spark-client-local/spark-client/distribution/documentation/images/VSCode-6.png inflating: spark-client-local/spark-client/distribution/documentation/images/IntelliJ-3.JPG inflating: spark-client-local/spark-client/distribution/documentation/images/VSCode-2.png inflating: spark-client-local/spark-client/distribution/documentation/images/IntelliJ-10.JPG inflating: spark-client-local/spark-client/distribution/documentation/images/login-dialog.png inflating: spark-client-local/spark-client/distribution/documentation/images/eclipse-maven-step-1.png inflating: spark-client-local/spark-client/distribution/documentation/images/IntelliJ-6.JPG inflating: spark-client-local/spark-client/distribution/documentation/images/IntelliJ-1.JPG inflating: spark-client-local/spark-client/distribution/documentation/images/contact-list.png inflating: spark-client-local/spark-client/distribution/documentation/images/IntelliJ-9.JPG inflating: spark-client-local/spark-client/distribution/documentation/images/IntelliJ-5.JPG inflating: spark-client-local/spark-client/distribution/documentation/images/VSCode-1.png inflating: spark-client-local/spark-client/distribution/documentation/images/chat-room.png inflating: spark-client-local/spark-client/distribution/documentation/images/eclipse-maven-step-5.png inflating: spark-client-local/spark-client/distribution/documentation/images/VSCode-5.png inflating: spark-client-local/spark-client/distribution/documentation/images/eclipse-maven-step-6.png inflating: spark-client-local/spark-client/distribution/documentation/images/IntelliJ-2.JPG inflating: spark-client-local/spark-client/distribution/documentation/images/banner-spring.gif inflating: spark-client-local/spark-client/distribution/documentation/images/eclipse-maven-step-2.png inflating: spark-client-local/spark-client/distribution/documentation/images/eclipse-maven-step-3.png inflating: spark-client-local/spark-client/distribution/documentation/images/IntelliJ-7.JPG inflating: spark-client-local/spark-client/distribution/documentation/images/eclipse-maven-step-4.png inflating: spark-client-local/spark-client/distribution/documentation/images/VSCode-3.png extracting: spark-client-local/spark-client/distribution/documentation/images/banner-spark.gif inflating: spark-client-local/spark-client/distribution/documentation/images/IntelliJ-4.JPG inflating: spark-client-local/spark-client/distribution/documentation/sample_plugin_repository.xml inflating: spark-client-local/spark-client/distribution/documentation/changes.xsl inflating: spark-client-local/spark-client/distribution/documentation/ide-eclipse-setup.html inflating: spark-client-local/spark-client/distribution/documentation/style.css inflating: spark-client-local/spark-client/distribution/documentation/LICENSE.html inflating: spark-client-local/spark-client/distribution/documentation/builder.jar inflating: spark-client-local/spark-client/distribution/documentation/sparkplug_dev_guide.html inflating: spark-client-local/spark-client/distribution/documentation/README.html creating: spark-client-local/spark-client/distribution/xtra/ creating: spark-client-local/spark-client/distribution/xtra/emoticons/ extracting: spark-client-local/spark-client/distribution/xtra/emoticons/sparkEmoticonSet.zip extracting: spark-client-local/spark-client/distribution/xtra/emoticons/GTalk.AdiumEmoticonset.zip extracting: spark-client-local/spark-client/distribution/xtra/emoticons/Default.adiumemoticonset.zip extracting: spark-client-local/spark-client/distribution/xtra/emoticons/POPO.adiumemoticonset.zip creating: spark-client-local/spark-client/distribution/lib/ inflating: spark-client-local/spark-client/distribution/lib/jxmpp-jid-1.0.3.jar inflating: spark-client-local/spark-client/distribution/lib/smack-debug-4.4.8.jar inflating: spark-client-local/spark-client/distribution/lib/bcpkix-jdk18on-1.78.1.jar inflating: spark-client-local/spark-client/distribution/lib/flatlaf-3.1.1.jar inflating: spark-client-local/spark-client/distribution/lib/minidns-core-1.0.5.jar creating: spark-client-local/spark-client/distribution/lib/linux/ inflating: spark-client-local/spark-client/distribution/lib/linux/libcivil.so inflating: spark-client-local/spark-client/distribution/lib/linux/libjng722.so inflating: spark-client-local/spark-client/distribution/lib/linux/libjnvpx.so inflating: spark-client-local/spark-client/distribution/lib/linux/libjnscreencapture.so inflating: spark-client-local/spark-client/distribution/lib/linux/libjnspeex.so inflating: spark-client-local/spark-client/distribution/lib/linux/libjnpulseaudio.so inflating: spark-client-local/spark-client/distribution/lib/linux/libjnvideo4linux2.so inflating: spark-client-local/spark-client/distribution/lib/linux/libjnawtrenderer.so inflating: spark-client-local/spark-client/distribution/lib/linux/libjnopus.so inflating: spark-client-local/spark-client/distribution/lib/linux/libjnffmpeg.so inflating: spark-client-local/spark-client/distribution/lib/linux/libjnportaudio.so inflating: spark-client-local/spark-client/distribution/lib/jna-platform-5.12.1.jar inflating: spark-client-local/spark-client/distribution/lib/jaxen-1.2.0.jar inflating: spark-client-local/spark-client/distribution/lib/slf4j-api-1.8.0-beta4.jar inflating: spark-client-local/spark-client/distribution/lib/bcutil-jdk18on-1.78.1.jar inflating: spark-client-local/spark-client/distribution/lib/swingx-all-1.6.5-1.jar inflating: spark-client-local/spark-client/distribution/lib/smack-xmlparser-4.4.8.jar inflating: spark-client-local/spark-client/distribution/lib/smack-legacy-4.4.8.jar inflating: spark-client-local/spark-client/distribution/lib/smack-tcp-4.4.8.jar inflating: spark-client-local/spark-client/distribution/lib/commons-lang3-3.15.0.jar inflating: spark-client-local/spark-client/distribution/lib/xstream-1.4.20.jar creating: spark-client-local/spark-client/distribution/lib/mac/ inflating: spark-client-local/spark-client/distribution/lib/mac/libjng722.jnilib inflating: spark-client-local/spark-client/distribution/lib/mac/libSystemUtilities.jnilib inflating: spark-client-local/spark-client/distribution/lib/mac/libjnspeex.jnilib inflating: spark-client-local/spark-client/distribution/lib/mac/JavaSoundStream.fix.jar inflating: spark-client-local/spark-client/distribution/lib/mac/libjnscreencapture.jnilib inflating: spark-client-local/spark-client/distribution/lib/mac/libjnopus.jnilib inflating: spark-client-local/spark-client/distribution/lib/mac/libjnffmpeg.jnilib inflating: spark-client-local/spark-client/distribution/lib/mac/libjnportaudio.jnilib inflating: spark-client-local/spark-client/distribution/lib/mac/libjnquicktime.jnilib inflating: spark-client-local/spark-client/distribution/lib/mac/libjnawtrenderer.jnilib inflating: spark-client-local/spark-client/distribution/lib/mac/libjnmaccoreaudio.jnilib inflating: spark-client-local/spark-client/distribution/lib/mac/libjnvpx.jnilib inflating: spark-client-local/spark-client/distribution/lib/bctls-jdk18on-1.78.1.jar inflating: spark-client-local/spark-client/distribution/lib/dom4j-2.1.4.jar inflating: spark-client-local/spark-client/distribution/lib/spark-core-3.0.3-SNAPSHOT.jar inflating: spark-client-local/spark-client/distribution/lib/smack-java8-4.4.8.jar inflating: spark-client-local/spark-client/distribution/lib/smack-debug-slf4j-4.4.8.jar creating: spark-client-local/spark-client/distribution/lib/windows64/ inflating: spark-client-local/spark-client/distribution/lib/windows64/jng722.dll inflating: spark-client-local/spark-client/distribution/lib/windows64/jnvpx.dll inflating: spark-client-local/spark-client/distribution/lib/windows64/jnffmpeg.dll inflating: spark-client-local/spark-client/distribution/lib/windows64/civil.dll inflating: spark-client-local/spark-client/distribution/lib/windows64/jnopus.dll inflating: spark-client-local/spark-client/distribution/lib/windows64/jndirectshow.dll inflating: spark-client-local/spark-client/distribution/lib/windows64/jnwasapi.dll inflating: spark-client-local/spark-client/distribution/lib/windows64/jnspeex.dll inflating: spark-client-local/spark-client/distribution/lib/windows64/jnwincoreaudio.dll inflating: spark-client-local/spark-client/distribution/lib/windows64/jnscreencapture.dll inflating: spark-client-local/spark-client/distribution/lib/windows64/jnportaudio.dll inflating: spark-client-local/spark-client/distribution/lib/windows64/jnawtrenderer.dll inflating: spark-client-local/spark-client/distribution/lib/mxparser-1.2.2.jar creating: spark-client-local/spark-client/distribution/lib/linux64/ inflating: spark-client-local/spark-client/distribution/lib/linux64/libcivil.so inflating: spark-client-local/spark-client/distribution/lib/linux64/libjng722.so inflating: spark-client-local/spark-client/distribution/lib/linux64/libjnvpx.so inflating: spark-client-local/spark-client/distribution/lib/linux64/libodbcinst.so inflating: spark-client-local/spark-client/distribution/lib/linux64/libjnscreencapture.so inflating: spark-client-local/spark-client/distribution/lib/linux64/libodbc.so inflating: spark-client-local/spark-client/distribution/lib/linux64/libjnspeex.so inflating: spark-client-local/spark-client/distribution/lib/linux64/libjnpulseaudio.so inflating: spark-client-local/spark-client/distribution/lib/linux64/libjnvideo4linux2.so inflating: spark-client-local/spark-client/distribution/lib/linux64/libjnawtrenderer.so inflating: spark-client-local/spark-client/distribution/lib/linux64/libjnopus.so inflating: spark-client-local/spark-client/distribution/lib/linux64/libjnffmpeg.so inflating: spark-client-local/spark-client/distribution/lib/linux64/libjnportaudio.so inflating: spark-client-local/spark-client/distribution/lib/jaxb-api-2.3.1.jar inflating: spark-client-local/spark-client/distribution/lib/httpcore5-h2-5.2.4.jar inflating: spark-client-local/spark-client/distribution/lib/smack-resolver-javax-4.4.8.jar inflating: spark-client-local/spark-client/distribution/lib/jxmpp-core-1.0.3.jar inflating: spark-client-local/spark-client/distribution/lib/install4j-runtime-11.0.4.jar inflating: spark-client-local/spark-client/distribution/lib/jna-5.12.1.jar inflating: spark-client-local/spark-client/distribution/lib/smack-sasl-javax-4.4.8.jar inflating: spark-client-local/spark-client/distribution/lib/javax.activation-api-1.2.0.jar inflating: spark-client-local/spark-client/distribution/lib/smack-extensions-4.4.8.jar inflating: spark-client-local/spark-client/distribution/lib/smack-im-4.4.8.jar inflating: spark-client-local/spark-client/distribution/lib/smack-xmlparser-stax-4.4.8.jar inflating: spark-client-local/spark-client/distribution/lib/thumbnailator-0.4.20.jar inflating: spark-client-local/spark-client/distribution/lib/xmlpull-1.1.3.1.jar inflating: spark-client-local/spark-client/distribution/lib/LoboBrowser-1.0.0.jar creating: spark-client-local/spark-client/distribution/lib/windows/ inflating: spark-client-local/spark-client/distribution/lib/windows/jng722.dll inflating: spark-client-local/spark-client/distribution/lib/windows/jnvpx.dll inflating: spark-client-local/spark-client/distribution/lib/windows/jnffmpeg.dll inflating: spark-client-local/spark-client/distribution/lib/windows/civil.dll inflating: spark-client-local/spark-client/distribution/lib/windows/jnopus.dll inflating: spark-client-local/spark-client/distribution/lib/windows/jndirectshow.dll inflating: spark-client-local/spark-client/distribution/lib/windows/jnwasapi.dll inflating: spark-client-local/spark-client/distribution/lib/windows/jnspeex.dll inflating: spark-client-local/spark-client/distribution/lib/windows/jnwincoreaudio.dll inflating: spark-client-local/spark-client/distribution/lib/windows/jnscreencapture.dll inflating: spark-client-local/spark-client/distribution/lib/windows/jnportaudio.dll inflating: spark-client-local/spark-client/distribution/lib/windows/jnawtrenderer.dll inflating: spark-client-local/spark-client/distribution/lib/httpclient5-5.2.3.jar inflating: spark-client-local/spark-client/distribution/lib/httpcore5-5.2.4.jar inflating: spark-client-local/spark-client/distribution/lib/smack-experimental-4.4.8.jar inflating: spark-client-local/spark-client/distribution/lib/smack-streammanagement-4.4.8.jar inflating: spark-client-local/spark-client/distribution/lib/hsluv-0.2.jar inflating: spark-client-local/spark-client/distribution/lib/smack-core-4.4.8.jar inflating: spark-client-local/spark-client/distribution/lib/jxmpp-util-cache-1.0.3.jar inflating: spark-client-local/spark-client/distribution/lib/bcprov-jdk18on-1.78.1.jar creating: spark-client-local/spark-client/distribution/security/ creating: spark-client-local/spark-client/distribution/bin/ inflating: spark-client-local/spark-client/distribution/bin/startup.bat inflating: spark-client-local/spark-client/distribution/bin/startup.sh [root@yfw Spark-master]# cd spark-client-local/distribution -bash: cd: spark-client-local/distribution: No such file or directory [root@yfw Spark-master]# ls -la 总用量 69312 drwxr-xr-x 10 root root 4096 10月 30 16:05 . drwxr-xr-x 4 openfire openfire 4096 10月 30 14:58 .. drwxr-xr-x 4 root root 4096 10月 30 15:33 core drwxr-xr-x 4 root root 4096 10月 30 15:33 distribution -rw-r--r-- 1 root root 311 10月 21 17:54 .editorconfig drwxr-xr-x 3 root root 4096 10月 21 17:54 emoticons -rw-r--r-- 1 root root 911 10月 21 17:54 .gitattributes drwxr-xr-x 3 root root 4096 10月 21 17:54 .github -rw-r--r-- 1 root root 441 10月 21 17:54 .gitignore drwxr-xr-x 2 root root 4096 10月 21 17:54 .idea -rw-r--r-- 1 root root 11357 10月 21 17:54 LICENSE.txt drwxr-xr-x 22 root root 4096 10月 21 17:54 plugins -rw-r--r-- 1 root root 5049 10月 21 17:54 pom.xml -rw-r--r-- 1 root root 2592 10月 21 17:54 README.md -rw-r--r-- 1 root root 455 10月 21 17:54 SECURITY.md drwxr-xr-x 3 root root 4096 10月 30 15:36 spark-client drwxr-xr-x 3 root root 4096 10月 30 16:05 spark-client-local -rw-r--r-- 1 root root 70884318 10月 30 16:04 spark-client.zip -rw-r--r-- 1 root root 1901 10月 21 17:54 .transifex.yml [root@yfw Spark-master]#
10-31
下载方式:https://pan.quark.cn/s/a4b39357ea24 布线问题(分支限界算法)是计算机科学和电子工程领域中一个广为人知的议题,它主要探讨如何在印刷电路板上定位两个节点间最短的连接路径。 在这一议题中,电路板被构建为一个包含 n×m 个方格的矩阵,每个方格能够被界定为可通行或不可通行,其核心任务是定位从初始点到最终点的最短路径。 分支限界算法是处理布线问题的一种常用策略。 该算法与回溯法有相似之处,但存在差异,分支限界法仅需获取满足约束条件的一个最优路径,并按照广度优先或最小成本优先的原则来探索解空间树。 树 T 被构建为子集树或排列树,在探索过程中,每个节点仅被赋予一次成为扩展节点的机会,且会一次性生成其全部子节点。 针对布线问题的解决,队列式分支限界法可以被采用。 从起始位置 a 出发,将其设定为首个扩展节点,并将与该扩展节点相邻且可通行的方格加入至活跃节点队列中,将这些方格标记为 1,即从起始方格 a 到这些方格的距离为 1。 随后,从活跃节点队列中提取队首节点作为下一个扩展节点,并将与当前扩展节点相邻且未标记的方格标记为 2,随后将这些方格存入活跃节点队列。 这一过程将持续进行,直至算法探测到目标方格 b 或活跃节点队列为空。 在实现上述算法时,必须定义一个类 Position 来表征电路板上方格的位置,其成员 row 和 col 分别指示方格所在的行和列。 在方格位置上,布线能够沿右、下、左、上四个方向展开。 这四个方向的移动分别被记为 0、1、2、3。 下述表格中,offset[i].row 和 offset[i].col(i=0,1,2,3)分别提供了沿这四个方向前进 1 步相对于当前方格的相对位移。 在 Java 编程语言中,可以使用二维数组...
源码来自:https://pan.quark.cn/s/a4b39357ea24 在VC++开发过程中,对话框(CDialog)作为典型的用户界面组件,承担着与用户进行信息交互的重要角色。 在VS2008SP1的开发环境中,常常需要满足为对话框配置个性化背景图片的需求,以此来优化用户的操作体验。 本案例将系统性地阐述在CDialog框架下如何达成这一功能。 首先,需要在资源设计工具中构建一个新的对话框资源。 具体操作是在Visual Studio平台中,进入资源视图(Resource View)界面,定位到对话框(Dialog)分支,通过右键选择“插入对话框”(Insert Dialog)选项。 完成对话框内控件的布局设计后,对对话框资源进行保存。 随后,将着手进行背景图片的载入工作。 通常有两种主要的技术路径:1. **运用位图控件(CStatic)**:在对话框界面中嵌入一个CStatic控件,并将其属性设置为BST_OWNERDRAW,从而具备自主控制绘制过程的权限。 在对话框的类定义中,需要重写OnPaint()函数,负责调用图片资源并借助CDC对象将其渲染到对话框表面。 此外,必须合理处理WM_CTLCOLORSTATIC消息,确保背景图片的展示不会受到其他界面元素的干扰。 ```cppvoid CMyDialog::OnPaint(){ CPaintDC dc(this); // 生成设备上下文对象 CBitmap bitmap; bitmap.LoadBitmap(IDC_BITMAP_BACKGROUND); // 获取背景图片资源 CDC memDC; memDC.CreateCompatibleDC(&dc); CBitmap* pOldBitmap = m...
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值