Java Util Base64 Example Java 7
- Java Software
- Java SE Downloads
- Java SE 8 Documentation
Enhancements in Packages java.lang.* and java.util.*
The following topics are covered:
- Enhancements in Java SE 8
- Enhancements in Java SE 7
- Enhancements in Java SE 6
- Enhancements in Java SE 5.0
- Enhancements in Java SE 1.4
- Enhancements in Java SE 1.3
Enhancements in Java SE 8
Parallel Array Sorting
The Parallel Array Sorting feature adds the same set of sorting operations currently provided by the Arrays class, but with a parallel implementation that utilizes the Fork/Join framework. Additional utility methods were added to java.util.Arrays that use the JSR 166 Fork/Join parallelism common pool to provide sorting of arrays in parallel. The methods are called parallelSort() and are overloaded for all the primitive data types and Comparable objects. See JEP 103 for more details.
The new methods are mentioned in the Java Tutorials (see Arrays and Fork/Join).
Standard Encoding and Decoding Base64
Applications that use base64 encoding schemes include Multipurpose Internet Mail Extensions (MIME) and encode passwords for HTTP headers. These applications encode and decode textual data. A new API for base64 encoding and decoding has been introduced in the
java.util package. The Base64 class defines factory methods to get Encoder and Decoder instances that encode and decode base64 data. Base64Sample and Base64Sample2 are code samples that demonstrate the Base64 class. See JEP 135: Base64 Encoding and Decoding for more details.
Unsigned Arithmetic Support
Methods were added to the Java Libraries to support unsigned integer arithmetic. Integers are 32-bits numbers out of which 1 bit is reserved for the sign but using these unsigned methods one can use all the 32 bits. Static methods such as parseUnsignedLong, toUnsignedString, divideUnsigned, compareUnsigned were added to the Long class and methods such as divideUnsigned, compareUnsigned, parseUnsignedInt, remainderUnsigned, toUnsignedString were added to the Integer class. These methods are faster than using the BigDecimal and BigInteger for arithmetic opearations as these include optimizations of primitive datatypes.
Other issues in Java SE 8
Area: Core Libraries / java.lang.reflect
Synopsis: The java.lang.reflect.Proxy(InvocationHandler h) constructor now throws a NullPointerException if the given InvocationHandler parameter is null.
Nature of Incompatibility: behavioral
Description: Existing code that constructs a dynamic proxy instance with a null argument will now get NullPointerException. Such usage is expected to rarely exist since a null proxy instance has no use and will throw a NullPointerException when its method is invoked anyway.
RFE: 4487672.
Enhancements in Java SE 7
- Multithreaded Custom Class Loaders in Java SE 7 - Potential deadlocks were eliminated for multithreaded, non-hierarchically delegating custom class loaders.
In addition, the following enhancements are introduced:
Area: API: Language
Standard/Platform: Java SE 7
Synopsis: Class loading can be prone to deadlocks if custom class loaders do not adhere to an acyclic class loader delegation model. New APIs have been added to the java.lang.ClassLoader class to support parallel loading of classes and finer-grained locking mechanism for class loading operations. Custom class loaders which would like to leverage this functionality must refer to the Class Loader API Modifications for Deadlock Fix documentation for the suggested model and requirements and be implemented accordingly.
Area: API: Language
Standard/Platform: JDK 7
Synopsis: Previously, the two exception types in the javax.lang.model.type package, MirroredTypeException and MirroredTypesException, were unrelated. In the javac implementation, MirroredTypeException was thrown where MirroredTypesException should have been thrown. In part to address this problem, MirroredTypeException was made a subclass of MirroredTypesException. This change is binary compatible and generally preserves the behavior of existing annotation processors. However, it is possible this change may cause source incompatibilities for client programs; in those cases, changing the order of catch clauses should allow the programs to compile again.
Area: API: Language
Standard/Platform: JDK 7
Synopsis: To model the language changes in this release, several updates were made to javax.lang.model.* including adding a method to the javax.lang.model.type.TypeVisitor interface. Such an addition is source incompatible with libraries that have directly implemented the TypeVisitor interface. However, such additions were foreseen as part of this API's evolution and libraries were explicitly cautioned to extend one of the utility visitors instead of directly implementing such an interface.
RFE: 6933147
Area: API: Language
Standard/Platform: JDK 7
Synopsis: The method Runtime.exec(String command, String[] envp, File dir) breaks the command string into tokens, consisting of the name of the executable and its arguments, by the invocation new StringTokenizer(command) with the default delimiter set (the space character, the tab character, the newline character, the carriage-return character, and the form-feed character). Essentially, this method splits the command string into tokens, using white space as the delimiter.
On Windows operating systems, splitting the command parameter by white spaces can lead to errors. In particular, if the command parameter contains an executable path with spaces, the invocation new StringTokenizer(command) extracts the wrong executable name. For example, the invocation Runtime.getRuntime().exec("C:\\My Programs\\foo.exe bar") attempts to launch the program C:\My with the arguments Programs\foo.exe and bar. This invocation is likely to fail with an exception to indicate that the executable C:\My cannot be found.
If your legacy application is not using a security manager (see the class SecurityManager), you can specify the system property jdk.lang.Process.allowAmbigousCommands with any value other than false so that the method Runtime.exec correctly parses path names with spaces. (See System Properties in The Java Tutorials.) Alternatively, you can surround the path name with quotation marks. For example, the invocation Runtime.getRuntime().exec("\"C:\\My Programs\\foo.exe\" bar") attempts to launch C:\My Programs\foo.exe with the argument bar.
Note: For updates after Update 25, the name of the system property to allow ambiguous commands is jdk.lang.Process.allowAmbiguousCommands.
Area: API: Utilities
Standard/Platform: JDK 7
Synopsis: Due to an error in java.util.TreeMap, it was previously possible to insert invalid null elements and elements not implementing Comparable into empty TreeMaps and TreeSets. Only a single invalid element could be inserted into the empty TreeMaps or TreeSets; additional elements would cause the expected NullPointerException or ClassCastException. Most other operations upon the collection would also fail. As of JDK 7, inserting an invalid null element or an element not implementing Comparable into an empty TreeMap or TreeSet throws a NullPointerException. RFE: 5045147
Enhancements in Java SE 6
java.util
- ServiceLoader - A facility to load a specific implementation of a service.
- Collections Framework Enhancements - There are many enhancements to the Collections framework.
Enhancements in Java SE 5.0
java.lang
- ProcessBuilder - The new
ProcessBuilderclass provides a more convenient way to invoke subprocesses than does Runtime.exec. In particular, ProcessBuilder makes it easy to start a subprocess with a modified process environment (that is, one based on the parent's process environment, but with a few changes). - Threads - The
java.lang.Threadclass has the following enhancements:- Thread priority handling has changed.
-
Thread.Stateenum class and the newgetState()API are provided for querying the execution state of a thread. - The new thread dump API - The
getStackTraceandgetAllStackTracesmethods in theThreadclass - provides a programmatic way to obtain the stack trace of a thread or all threads. - The
uncaughtExceptionHandlermechanism, previously available only through the ThreadGroup class, is now available directly through the Thread class. - A new form of the
sleep()method is provided which allows for sleep times smaller than one millisecond.
java.lang.instrument
- Instrumentation - The new
java.lang.instrumentpackage provides services that allow Java programming agents to instrument programs running on the Java virtual machine by modifying methods' bytecodes at runtime.
java.util
- Formatter - An interpreter for printf-style format strings, the
Formatterclass provides support for layout justification and alignment, common formats for numeric, string, and date/time data, and locale-specific output. Common Java types such asbyte,java.math.BigDecimal, andjava.util.Calendarare supported. Limited formatting customization for arbitrary user types is provided through thejava.util.Formattableinterface. - Scanner - The
java.util.Scannerclass can be used to convert text into primitives orStrings. Since it is based on thejava.util.regexpackage, it also offers a way to conduct regular expression based searches on streams, file data, strings, or implementors of theReadableinterface. - Collections Framework Enhancements - There are many enhancements to the Collections framework.
Enhancements in Java SE 1.4
java.lang
- Chained Exception Facility - This is a new facility that provides a common API to record the fact that one exception caused another, to access causative exceptions, and to acess the entire "causal chain" as part of the standard stack backtrace, ensuring that preexisting programs will provide this information with no additional effort on the part of their authors.
- String - Two
splitmethods are new. ThesubSequencemethod has been added, as required by theCharSequenceinterface thatStringnow implements. Three additional methods have been added:matches,replaceAll, andreplaceFirst. - StringBuffer - The
subSequencemethod has been added, as required by theCharSequenceinterface thatStringBuffernow implements. - Thread - The
interruptmethod has been revised to interrupt threads blocked in channel-I/O operations.
java.util.logging
- Logging API - The Java Logging API facilitates software servicing and maintenance at customer sites by producing log reports suitable for analysis by end users, system administrators, field service engineers, and software development teams. The Logging APIs capture information such as security failures, configuration errors, performance bottlenecks, and/or bugs in the application or platform. The core package includes support for delivering plain text or XML formatted log records to memory, output streams, consoles, files, and sockets. In addition, the logging APIs are capable of interacting with logging services that already exist on the host operating system.
java.util.prefs
- Preferences API - The preferences API, implemented by package
java.util.prefs, allows applications to store and retrieve user and system preference and configuration data. This data is stored persistently in an implementation-dependent backing store. The Preferences API is intended to replace most common uses of classjava.util.Properties, rectifying many of its deficiencies, while retaining its light weight.
Enhancements in Java SE 1.3
java.lang
- java.lang.Math and java.lang.StrictMath - Two new classes which provide APIs for performing general numeric operations.
-
java.lang.StrictMath- Classjava.lang.StrictMathhas the same API as old classjava.lang.Math, which was present in previous versions of the Java platform. Unlike classMath, however,StrictMathis defined to return bit-for-bit reproducible results in all implementations. -
java.lang.Math- Classjava.lang.Mathprovides the same set of API as does classStrictMath. However, unlike some of the numeric functions of classStrictMath, all implementations of the equivalent functions of classMathare not defined to return the bit-for-bit same results, but can vary within specified constraints. This permits better-performing implementations where strict reproducibility is not required.
-
- Timer API - Two new classes to provide an API for a timer facility which can be used for purposes such as animations, human interaction timeouts, on-screen clocks and calendars, work-scheduling routines, reminder facilities, and more.
-
java.util.Timer -
java.util.TimerTask
Countdown.javais a simple demo application that uses the Timer API. -
- Virtual Machine Shutdown Hooks Sophisticated applications often require the ability to perform specific actions when the virtual machine shuts down, whether due to voluntary exit or involuntary termination. Typical actions include cleanly closing down network connections, saving session state, and deleting temporary files. Every major operating system provides the means for native applications to do this, though of course the details vary from platform to platform. Three methods have been added to
java.lang.Runtimeto provide a simple and portable interface to these facitilies. The new methods are:-
addShutdownHook -
removeShutdownHook -
halt
Runtime.exitmethod has been revised. For more information, see Design of the Shutdown Hooks API. -
java.util
- Enhanced Collections Framework - The Collections Framework has these new convenience APIs:
- Added Collections.singletonList and Collections.singletonMap. Previously, there was a convenience implementation for singleton Set, but no corresponding implementation for List and Map. Both of these implementations proved desirable in practice.
- Added Collections.EMPTY_MAP. Previously, there were constant convenience implementations for the empty Set and List, but no corresponding implementation for Map.
- Added Map constuctor for WeakHashMap. The Map interface dictates that most Map implementations should have a "copy constructor" that takes a Map argument. WeakHashMap lacked such a constructor in the 1.2 release.
java.util.jar
java.util.zip
- New URL JAR File Caching - The API of classes
java.util.zipandjava.util.jarhave been enhanced with the addition of the following:-
java.util.zip.OPEN_READ -
java.util.zip.OPEN_DELETE -
java.util.zip.ZipFile(File file, int mode) -
java.util.jar.JarFile(File file, boolean verify, int mode)
The previous implementation of caching downloaded Jar files created problems for long-running server application and for RMI. Each openJarURLConnectioncreates a temporary local file that holds Jar-file date, and a JarFile object is created on top of the temporary file. Because the open file handle/descriptor on each temporary file was never closed, the files could quickly take up disk space for long-running server applications. The new API provides a solution for this problem by supporting a new "delete-on-close" mode for opening Zip and Jar files. -
Source: https://docs.oracle.com/javase/8/docs/technotes/guides/lang/enhancements.html
0 Response to "Java Util Base64 Example Java 7"
Post a Comment