Source Code Cross Referenced for FDOutputStream.java in  » 6.0-JDK-Modules » j2me » sun » io » 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 » 6.0 JDK Modules » j2me » sun.io 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * @(#)FDOutputStream.java	1.37 06/10/10
003:         *
004:         * Copyright  1990-2006 Sun Microsystems, Inc. All Rights Reserved.
005:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006:         * 
007:         * This program is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU General Public License version
009:         * 2 only, as published by the Free Software Foundation. 
010:         * 
011:         * This program is distributed in the hope that it will be useful, but
012:         * WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014:         * General Public License version 2 for more details (a copy is
015:         * included at /legal/license.txt). 
016:         * 
017:         * You should have received a copy of the GNU General Public License
018:         * version 2 along with this work; if not, write to the Free Software
019:         * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020:         * 02110-1301 USA 
021:         * 
022:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023:         * Clara, CA 95054 or visit www.sun.com if you need additional
024:         * information or have any questions. 
025:         *
026:         */
027:
028:        package sun.io;
029:
030:        import java.io.*;
031:
032:        /**
033:         * A file output stream is an output stream for writing data to a 
034:         * <code>File</code> or to a <code>FileDescriptor</code>. 
035:         *
036:         * @author  Arthur van Hoff
037:         * @version 1.33, 08/19/02
038:         * @see     java.io.File
039:         * @see     java.io.FileDescriptor
040:         * @see     java.io.FileInputStream
041:         * @since   JDK1.0
042:         */
043:        public class FDOutputStream extends OutputStream {
044:            static {
045:                java.security.AccessController
046:                        .doPrivileged(new sun.security.action.LoadLibraryAction(
047:                                "javafile"));
048:            }
049:            /**
050:             * The system dependent file descriptor. The value is
051:             * 1 more than actual file descriptor. This means that
052:             * the default value 0 indicates that the file is not open.
053:             */
054:            private FileDescriptor fd;
055:
056:            /**
057:             * Creates an output file stream to write to the file with the 
058:             * specified name. 
059:             *
060:             * @param      name   the system-dependent filename.
061:             * @exception  IOException  if the file could not be opened for writing.
062:             * @exception  SecurityException  if a security manager exists, its
063:             *               <code>checkWrite</code> method is called with the name
064:             *               argument to see if the application is allowed write access
065:             *               to the file.
066:             * @see        java.lang.SecurityManager#checkWrite(java.lang.String)
067:             * @since      JDK1.0
068:             */
069:            public FDOutputStream(String name) throws IOException {
070:                SecurityManager security = System.getSecurityManager();
071:                if (security != null) {
072:                    security.checkWrite(name);
073:                }
074:                try {
075:                    fd = new FileDescriptor();
076:                    open(name);
077:                } catch (IOException e) {
078:                    throw new IOException(name);
079:                }
080:            }
081:
082:            /**
083:             * Creates an output file with the specified system dependent
084:             * file name.
085:             * @param name the system dependent file name 
086:             * @exception IOException If the file is not found.
087:             * @since     JDK1.1
088:             */
089:            public FDOutputStream(String name, boolean append)
090:                    throws IOException {
091:                SecurityManager security = System.getSecurityManager();
092:                if (security != null) {
093:                    security.checkWrite(name);
094:                }
095:                try {
096:                    fd = new FileDescriptor();
097:                    if (append)
098:                        openAppend(name);
099:                    else
100:                        open(name);
101:                } catch (IOException e) {
102:                    throw new IOException(name);
103:                }
104:            }
105:
106:            /**
107:             * Creates an output file stream to write to the specified file descriptor.
108:             *
109:             * @param      fdObj   the file descriptor to be opened for writing.
110:             * @exception  SecurityException  if a security manager exists, its
111:             *               <code>checkWrite</code> method is called with the file
112:             *               descriptor to see if the application is allowed to write
113:             *               to the specified file descriptor.
114:             * @see        java.lang.SecurityManager#checkWrite(java.io.FileDescriptor)
115:             * @since      JDK1.0
116:             */
117:            public FDOutputStream(FileDescriptor fdObj) {
118:                SecurityManager security = System.getSecurityManager();
119:                if (fdObj == null) {
120:                    throw new NullPointerException();
121:                }
122:                if (security != null) {
123:                    security.checkWrite(fdObj);
124:                }
125:                fd = fdObj;
126:            }
127:
128:            /**
129:             * Opens a file, with the specified name, for writing.
130:             * @param name name of file to be opened
131:             */
132:            public native void open(String name) throws IOException;
133:
134:            /**
135:             * Opens a file, with the specified name, for appending.
136:             * @param name name of file to be opened
137:             */
138:            public native void openAppend(String name) throws IOException;
139:
140:            /**
141:             * Writes the specified byte to this file output stream. 
142:             *
143:             * @param      b   the byte to be written.
144:             * @exception  IOException  if an I/O error occurs.
145:             * @since      JDK1.0
146:             */
147:            public native void write(int b) throws IOException;
148:
149:            /**
150:             * Writes a sub array as a sequence of bytes.
151:             * @param b the data to be written
152:             * @param off the start offset in the data
153:             * @param len the number of bytes that are written
154:             * @exception IOException If an I/O error has occurred.
155:             */
156:            public native void writeBytes(byte b[], int off, int len)
157:                    throws IOException;
158:
159:            /**
160:             * Writes <code>b.length</code> bytes from the specified byte array 
161:             * to this file output stream. 
162:             *
163:             * @param      b   the data.
164:             * @exception  IOException  if an I/O error occurs.
165:             * @since      JDK1.0
166:             */
167:            public void write(byte b[]) throws IOException {
168:                writeBytes(b, 0, b.length);
169:            }
170:
171:            /**
172:             * Writes <code>len</code> bytes from the specified byte array 
173:             * starting at offset <code>off</code> to this file output stream. 
174:             *
175:             * @param      b     the data.
176:             * @param      off   the start offset in the data.
177:             * @param      len   the number of bytes to write.
178:             * @exception  IOException  if an I/O error occurs.
179:             * @since      JDK1.0
180:             */
181:            public void write(byte b[], int off, int len) throws IOException {
182:                writeBytes(b, off, len);
183:            }
184:
185:            /**
186:             * Closes this file output stream and releases any system resources 
187:             * associated with this stream. 
188:             *
189:             * @exception  IOException  if an I/O error occurs.
190:             * @since      JDK1.0
191:             */
192:            public native void close() throws IOException;
193:
194:            /**
195:             * Returns the file descriptor associated with this stream.
196:             *
197:             * @return  the file descriptor object associated with this stream.
198:             * @exception  IOException  if an I/O error occurs.
199:             * @see        java.io.FileDescriptor
200:             * @since      JDK1.0
201:             */
202:            public final FileDescriptor getFD() throws IOException {
203:                if (fd != null)
204:                    return fd;
205:                throw new IOException();
206:            }
207:
208:            /**
209:             * Ensures that the <code>close</code> method of this file output stream is
210:             * called when there are no more references to this stream. 
211:             *
212:             * @exception  IOException  if an I/O error occurs.
213:             * @see        java.io.FileInputStream#close()
214:             * @since      JDK1.0
215:             */
216:            protected void finalize() throws IOException {
217:                if (fd != null) {
218:                    if (fd == fd.out || fd == fd.err) {
219:                        flush();
220:                    } else {
221:                        close();
222:                    }
223:                }
224:            }
225:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.