Source Code Cross Referenced for FileInputStream.java in  » PDF » PDFClown-0.0.5 » it » stefanochizzolini » clown » bytes » 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 » PDF » PDFClown 0.0.5 » it.stefanochizzolini.clown.bytes 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:          Copyright © 2006,2007 Stefano Chizzolini. http://clown.stefanochizzolini.it
003:
004:          Contributors:
005:         * Stefano Chizzolini (original code developer, http://www.stefanochizzolini.it):
006:              contributed code is Copyright © 2006,2007 by Stefano Chizzolini.
007:
008:          This file should be part of the source code distribution of "PDF Clown library"
009:          (the Program): see the accompanying README files for more info.
010:
011:          This Program is free software; you can redistribute it and/or modify it under
012:          the terms of the GNU General Public License as published by the Free Software
013:          Foundation; either version 2 of the License, or (at your option) any later version.
014:
015:          This Program is distributed in the hope that it will be useful, but WITHOUT ANY
016:          WARRANTY, either expressed or implied; without even the implied warranty of
017:          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License for more details.
018:
019:          You should have received a copy of the GNU General Public License along with this
020:          Program (see README files); if not, go to the GNU website (http://www.gnu.org/).
021:
022:          Redistribution and use, with or without modification, are permitted provided that such
023:          redistributions retain the above copyright notice, license and disclaimer, along with
024:          this list of conditions.
025:         */
026:
027:        package it.stefanochizzolini.clown.bytes;
028:
029:        import java.io.RandomAccessFile;
030:        import java.io.EOFException;
031:        import java.io.IOException;
032:        import java.nio.ByteOrder;
033:
034:        /**
035:         File stream.
036:         @version 0.0.4
037:         */
038:        public final class FileInputStream implements  IInputStream {
039:            // <class>
040:            // <dynamic>
041:            // <fields>
042:            private RandomAccessFile file;
043:
044:            // </fields>
045:
046:            // <constructors>
047:            public FileInputStream(RandomAccessFile file) {
048:                this .file = file;
049:            }
050:
051:            // </constructors>
052:
053:            // <interface>
054:            // <public>
055:            // <IInputStream>
056:            public ByteOrder getByteOrder() {
057:                return ByteOrder.BIG_ENDIAN;
058:            }
059:
060:            public long getLength() {
061:                try {
062:                    return file.length();
063:                } catch (IOException e) {
064:                    throw new RuntimeException(e);
065:                }
066:            }
067:
068:            public long getPosition() {
069:                try {
070:                    return file.getFilePointer();
071:                } catch (IOException e) {
072:                    throw new RuntimeException(e);
073:                }
074:            }
075:
076:            public int hashCode() {
077:                return file.hashCode();
078:            }
079:
080:            public void read(byte[] data) throws EOFException {
081:                try {
082:                    file.readFully(data);
083:                } catch (EOFException e) {
084:                    throw e;
085:                } catch (IOException e) {
086:                    throw new RuntimeException(e);
087:                }
088:            }
089:
090:            public void read(byte[] data, int offset, int length)
091:                    throws EOFException {
092:                try {
093:                    file.readFully(data, offset, length);
094:                } catch (EOFException e) {
095:                    throw e;
096:                } catch (IOException e) {
097:                    throw new RuntimeException(e);
098:                }
099:            }
100:
101:            public byte readByte() throws EOFException {
102:                try {
103:                    return file.readByte();
104:                } catch (EOFException e) {
105:                    throw e;
106:                } catch (IOException e) {
107:                    throw new RuntimeException(e);
108:                }
109:            }
110:
111:            public int readInt() throws EOFException {
112:                try {
113:                    return file.readInt();
114:                } catch (EOFException e) {
115:                    throw e;
116:                } catch (IOException e) {
117:                    throw new RuntimeException(e);
118:                }
119:            }
120:
121:            public String readLine() throws EOFException {
122:                try {
123:                    return file.readLine();
124:                } catch (EOFException e) {
125:                    throw e;
126:                } catch (IOException e) {
127:                    throw new RuntimeException(e);
128:                }
129:            }
130:
131:            public short readShort() throws EOFException {
132:                try {
133:                    return file.readShort();
134:                } catch (EOFException e) {
135:                    throw e;
136:                } catch (IOException e) {
137:                    throw new RuntimeException(e);
138:                }
139:            }
140:
141:            public String readString(int length) throws EOFException {
142:                byte[] data = new byte[length];
143:                try {
144:                    file.readFully(data);
145:
146:                    return new String(data, "ISO-8859-1");
147:                } catch (EOFException e) {
148:                    throw e;
149:                } catch (Exception e) {
150:                    throw new RuntimeException(e);
151:                }
152:            }
153:
154:            public int readUnsignedByte() throws EOFException {
155:                try {
156:                    return file.readUnsignedByte();
157:                } catch (EOFException e) {
158:                    throw e;
159:                } catch (IOException e) {
160:                    throw new RuntimeException(e);
161:                }
162:            }
163:
164:            public int readUnsignedShort() throws EOFException {
165:                try {
166:                    return file.readUnsignedShort();
167:                } catch (EOFException e) {
168:                    throw e;
169:                } catch (IOException e) {
170:                    throw new RuntimeException(e);
171:                }
172:            }
173:
174:            public void seek(long offset) {
175:                try {
176:                    file.seek(offset);
177:                } catch (IOException e) {
178:                    throw new RuntimeException(e);
179:                }
180:            }
181:
182:            public void setByteOrder(ByteOrder value) {/* TODO */
183:            }
184:
185:            public void setPosition(long value) {
186:                try {
187:                    file.seek(value);
188:                } catch (IOException e) {
189:                    throw new RuntimeException(e);
190:                }
191:            }
192:
193:            public void skip(long offset) {
194:                try {
195:                    file.seek(file.getFilePointer() + offset);
196:                } catch (IOException e) {
197:                    throw new RuntimeException(e);
198:                }
199:            }
200:
201:            public byte[] toByteArray() {
202:                byte[] data = null;
203:                try {
204:                    file.seek(0);
205:                    data = new byte[(int) file.length()];
206:                    file.readFully(data);
207:                } catch (IOException e) {
208:                    throw new RuntimeException(e);
209:                }
210:
211:                return data;
212:            }
213:            // </IInputStream>
214:            // </public>
215:            // </interface>
216:            // </dynamic>
217:            // </class>
218:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.