Hex dump : Base64 Stream « File Input Output « Java

Java
1. 2D Graphics GUI
2. 3D
3. Advanced Graphics
4. Ant
5. Apache Common
6. Chart
7. Class
8. Collections Data Structure
9. Data Type
10. Database SQL JDBC
11. Design Pattern
12. Development Class
13. EJB3
14. Email
15. Event
16. File Input Output
17. Game
18. Generics
19. GWT
20. Hibernate
21. I18N
22. J2EE
23. J2ME
24. JDK 6
25. JNDI LDAP
26. JPA
27. JSP
28. JSTL
29. Language Basics
30. Network Protocol
31. PDF RTF
32. Reflection
33. Regular Expressions
34. Scripting
35. Security
36. Servlets
37. Spring
38. Swing Components
39. Swing JFC
40. SWT JFace Eclipse
41. Threads
42. Tiny Application
43. Velocity
44. Web Services SOA
45. XML
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java » File Input Output » Base64 StreamScreenshots 
Hex dump
    
/* jcifs smb client library in Java
 * Copyright (C) 2000  "Michael B. Allen" <jcifs at samba dot org>
 *                     "Christopher R. Hertel" <jcifs at samba dot org>
 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */


import java.io.OutputStream;
import java.io.PrintStream;

/**
 */

public class Hexdump {

    private static final String NL = System.getProperty"line.separator" );
    private static final int NL_LENGTH = NL.length();

    private static final char[] SPACE_CHARS = {
        ' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' ',
        ' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' ',
        ' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '
    };

    public static final char[] HEX_DIGITS = 
        '0''1''2''3''4''5',
        '6''7''8''9''A''B',
        'C''D''E''F'
    };

/** 
 * Generate "hexdump" output of the buffer at src like the following:
 *
 * <p><blockquote><pre>
 * 00000: 04 d2 29 00 00 01 00 00 00 00 00 01 20 45 47 46  |..)......... EGF|
 * 00010: 43 45 46 45 45 43 41 43 41 43 41 43 41 43 41 43  |CEFEECACACACACAC|
 * 00020: 41 43 41 43 41 43 41 43 41 43 41 41 44 00 00 20  |ACACACACACAAD.. |
 * 00030: 00 01 c0 0c 00 20 00 01 00 00 00 00 00 06 20 00  |..... ........ .|
 * 00040: ac 22 22 e1                                      |."".            |
 * </blockquote></pre>
 */

    public static void hexdumpPrintStream ps, byte[] src, int srcIndex, int length ) {
        iflength == ) {
            return;
        }

        int s = length % 16;
        int r = s == ? length / 16 : length / 16 1;
        char[] c = new char[r * (74 + NL_LENGTH)];
        char[] d = new char[16];
        int i;
        int si = 0;
        int ci = 0;

        do {
            toHexCharssi, c, ci, );
            ci += 5;
            c[ci++':';
            do {
                ifsi == length ) {
                    int n = 16 - s;
                    System.arraycopySPACE_CHARS, 0, c, ci, n * );
                    ci += n * 3;
                    System.arraycopySPACE_CHARS, 0, d, s, n );
                    break;
                }
                c[ci++' ';
                i = src[srcIndex + si0xFF;
                toHexCharsi, c, ci, );
                ci += 2
                ifi < || Character.isISOControl( (char))) {
                    d[si % 16'.';
                else {
                    d[si % 16(char)i;
                }
            while(( ++si % 16 != );
            c[ci++' ';
            c[ci++' ';
            c[ci++'|';
            System.arraycopyd, 0, c, ci, 16 );
            ci += 16;
            c[ci++'|';
            NL.getChars0, NL_LENGTH, c, ci );
            ci += NL_LENGTH;
        whilesi < length );

        ps.println);
    }

/** 
 * This is an alternative to the <code>java.lang.Integer.toHexString</cod>
 * method. It is an efficient relative that also will pad the left side so
 * that the result is <code>size</code> digits.
 */ 
    public static String toHexStringint val, int size ) {
        char[] c = new char[size];
        toHexCharsval, c, 0, size );
        return new String);
    }
    public static String toHexStringlong val, int size ) {
        char[] c = new char[size];
        toHexCharsval, c, 0, size );
        return new String);
    }
    public static String toHexStringbyte[] src, int srcIndex, int size ) {
        char[] c = new char[size];
        size = size % == ? size / : size / 1;
        forint i = 0, j = 0; i < size; i++ ) {
            c[j++= HEX_DIGITS[(src[i>> 0x0F];
            ifj == c.length ) {
                break;
            }
            c[j++= HEX_DIGITS[src[i0x0F];
        }
        return new String);
    }

/** 
 * This is the same as {@link jcifs.util.Hexdump#toHexString(int val, int
 * size)} but provides a more practical form when trying to avoid {@link
 * java.lang.String} concatenation and {@link java.lang.StringBuffer}.
 */ 
    public static void toHexCharsint val, char dst[]int dstIndex, int size ) {
        whilesize > ) {
            int i = dstIndex + size - 1;
            ifi < dst.length ) {
                dst[i= HEX_DIGITS[val & 0x000F];
            }
            ifval != ) {
                val >>>= 4;
            }
            size--;
        }
    }
    public static void toHexCharslong val, char dst[]int dstIndex, int size ) {
        whilesize > ) {
            dst[dstIndex + size - 1= HEX_DIGITS[(int)( val & 0x000FL )];
            ifval != ) {
                val >>>= 4;
            }
            size--;
        }
    }
}

   
    
    
    
  
Related examples in the same category
1. BASE64 Decoder Stream
2. BASE64 Encoder Stream from Sun Microsystems
3. Base64 Character decoder as specified in RFC1113.
4. Base64 Character encoder as specified in RFC1113.
5. Performs Base-64 decoding on an underlying stream.
6. Class encodes the bytes written to the OutPutStream to a Base64 encoded string.
7. BASE64 Decoder Stream from Sun Microsystems
8. BASE64 Encoder Stream
9. Decode a BASE64 encoded input stream to some output stream
10. Dumps data in hexadecimal format
11. Apply a ASCII Hex encoding to the stream
12. Base64 Codec
13. Base64 encoding from DbUnit.org
14. Base64 provides Base64 encoding/decoding of strings and streams
15. Base64 - encode/decode data using the Base64 encoding scheme
16. Base64 from Eric Glass jcifs at samba dot org
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.