File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes pattern for unmodifyable array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "pattern for unmodifyable array" Watch "pattern for unmodifyable array" New topic
Author

pattern for unmodifyable array

Gytis Jakutonis
Ranch Hand

Joined: Feb 02, 2004
Posts: 76
Hello,
I need to define final static array (with file signature bytes in my case), ant I'm not sure how to protect array from modifications. If I use simple form:

then malicious code may change signature elements:


So I came up with this idea:

Maybe there is some pattern for this problem, or maybe new jdk 1.5 has some standard elements, which slolve the issue?
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Better than a pattern, the java.util.Collections class contains methods to mark collections as unmodifiable. Have a look at those.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: pattern for unmodifyable array
 
Similar Threads
Audio format conversion problems
problem base64 encoding the 3 hex bytes E2 80 A9
Basic Authentication Servlet Redirect
How to validate a file to UTF-8 encoding
back and forth in a vector