Source Code Cross Referenced for ConvertAssist.java in  » Web-Mail » oyster » org » enhydra » oyster » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
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 Source Code / Java Documentation » Web Mail » oyster » org.enhydra.oyster.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Title:        Oyster Project
003:         * Description:  Creating S/MIME email transport capabilities.
004:         * Copyright:    Copyright (c) 2001
005:         * @Author       Vladimir Radisic
006:         * @Version      2.1.6
007:         */package org.enhydra.oyster.util;
008:
009:        import org.enhydra.oyster.exception.SMIMEException;
010:        import java.io.File;
011:        import java.io.FileInputStream;
012:        import java.io.InputStream;
013:        import java.io.IOException;
014:
015:        /**
016:         * This class contains static methods which make easier work and conversion
017:         * between different types under the large amount of data (arrays, streams,
018:         * files ...).
019:         */
020:        public class ConvertAssist {
021:
022:            /**
023:             * Reads data from input stream into the String.
024:             * @param in0 source of data for reading
025:             * @return data extracted from input stream represented as String
026:             * @exception SMIMEException caused by non SMIMEException which is IOException
027:             */
028:            public static String inStreamToString(InputStream in0)
029:                    throws SMIMEException {
030:
031:                String sAtach = new String();
032:                try {
033:                    byte[] b = new byte[100000];
034:                    int a = in0.read(b);
035:                    while (a == 100000) {
036:                        sAtach = sAtach.concat(new String(b, "ISO-8859-1"));
037:                        a = in0.read(b);
038:                    }
039:                    in0.close();
040:                    sAtach = sAtach.concat(new String(b, "ISO-8859-1")
041:                            .substring(0, a));
042:                } catch (IOException e) {
043:                    throw new SMIMEException(e);
044:                }
045:                return sAtach;
046:            }
047:
048:            /**
049:             * Reads data from input stream into the byte array.
050:             * @param in0 source of data for reading
051:             * @return data extracted from input stream represented as byte array
052:             * @exception SMIMEException caused by non SMIMEException which is IOException
053:             */
054:            public static byte[] inStreamToByteArray(InputStream in0)
055:                    throws SMIMEException {
056:
057:                byte[] returnArray = null;
058:                try {
059:                    returnArray = ConvertAssist.inStreamToString(in0).getBytes(
060:                            "ISO-8859-1");
061:                } catch (IOException e) {
062:                    throw new SMIMEException(e);
063:                }
064:
065:                return returnArray;
066:            }
067:
068:            /**
069:             * Reads data from file into the String.
070:             * @param file0 abstract path to file represented as File object
071:             * @return data from file represented as String
072:             * @exception SMIMEException caused by non SMIMEException which is IOException
073:             */
074:            public static String fileToString(File file0) throws SMIMEException {
075:
076:                String s = null;
077:                try {
078:                    FileInputStream temp = new FileInputStream(file0);
079:                    s = new String();
080:                    byte[] b = new byte[100000];
081:                    int a = temp.read(b);
082:                    while (a == 100000) {
083:                        s = s.concat(new String(b, "ISO-8859-1"));
084:                        a = temp.read(b);
085:                    }
086:                    temp.close();
087:                    s = s.concat(new String(b, "ISO-8859-1").substring(0, a));
088:                } catch (Exception e) {
089:                    throw new SMIMEException(e);
090:                }
091:                return s;
092:            }
093:
094:            /**
095:             * Reads data from file into the byte array.
096:             * @param file0 abstract path to file represented as File object
097:             * @return data from file represented as byte array
098:             * @exception SMIMEException caused by non SMIMEException which is IOException
099:             */
100:            public static byte[] fileToByteArray(File file0)
101:                    throws SMIMEException {
102:
103:                try {
104:                    return fileToString(file0).getBytes("ISO-8859-1");
105:                } catch (Exception e) {
106:                    throw new SMIMEException(e);
107:                }
108:            }
109:
110:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.