Source Code Cross Referenced for EchoWriter.java in  » GIS » GeoTools-2.4.1 » org » geotools » 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 » GIS » GeoTools 2.4.1 » org.geotools.io 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *    GeoTools - OpenSource mapping toolkit
003:         *    http://geotools.org
004:         *    (C) 2004-2006, GeoTools Project Managment Committee (PMC)
005:         *    (C) 2004, Institut de Recherche pour le Développement
006:         *
007:         *    This library is free software; you can redistribute it and/or
008:         *    modify it under the terms of the GNU Lesser General Public
009:         *    License as published by the Free Software Foundation;
010:         *    version 2.1 of the License.
011:         *
012:         *    This library is distributed in the hope that it will be useful,
013:         *    but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
015:         *    Lesser General Public License for more details.
016:         */
017:        package org.geotools.io;
018:
019:        // J2SE dependencies
020:        import java.io.FilterWriter;
021:        import java.io.IOException;
022:        import java.io.Writer;
023:
024:        /**
025:         * A writer that copy all output to an other stream. This writer can be used for perfoming
026:         * an exact copy of what is sent to an other writer. For example, it may be used for echoing
027:         * to the standard output the content sent to a file. This writer is usefull for debugging
028:         * purpose.
029:         *
030:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/metadata/src/main/java/org/geotools/io/EchoWriter.java $
031:         * @version $Id: EchoWriter.java 23632 2006-12-29 22:13:51Z desruisseaux $
032:         * @author Martin Desruisseaux
033:         *
034:         * @since 2.1
035:         */
036:        public class EchoWriter extends FilterWriter {
037:            /**
038:             * The echo writer.
039:             */
040:            private final Writer echo;
041:
042:            /**
043:             * Creates a writer that will echo to the {@linkplain System#out standard output}.
044:             * Each line to that standard output will be {@linkplain NumberedLineWriter numbered}.
045:             *
046:             * @param main The main stream.
047:             */
048:            public EchoWriter(final Writer main) {
049:                super (main);
050:                this .echo = NumberedLineWriter.OUT;
051:            }
052:
053:            /**
054:             * Creates a copy writter for the specified stream.
055:             *
056:             * @param main The main stream.
057:             * @param echo The echo stream.
058:             */
059:            public EchoWriter(final Writer main, final Writer echo) {
060:                super (main);
061:                this .echo = echo;
062:            }
063:
064:            /**
065:             * Write a single character.
066:             *
067:             * @throws IOException  If an I/O error occurs
068:             */
069:            public void write(final int c) throws IOException {
070:                synchronized (lock) {
071:                    out.write(c);
072:                    echo.write(c);
073:                }
074:            }
075:
076:            /**
077:             * Write an array of characters.
078:             *
079:             * @param  cbuf  Buffer of characters to be written
080:             * @throws IOException  If an I/O error occurs
081:             */
082:            public void write(final char[] cbuf) throws IOException {
083:                synchronized (lock) {
084:                    out.write(cbuf);
085:                    echo.write(cbuf);
086:                }
087:            }
088:
089:            /**
090:             * Write a portion of an array of characters.
091:             *
092:             * @param  cbuf  Buffer of characters to be written
093:             * @param  off   Offset from which to start reading characters
094:             * @param  len   Number of characters to be written
095:             * @throws IOException  If an I/O error occurs
096:             */
097:            public void write(final char[] cbuf, final int off, final int len)
098:                    throws IOException {
099:                synchronized (lock) {
100:                    out.write(cbuf, off, len);
101:                    echo.write(cbuf, off, len);
102:                }
103:            }
104:
105:            /**
106:             * Write a string.
107:             *
108:             * @param  str  String to be written
109:             * @throws IOException  If an I/O error occurs
110:             */
111:            public void write(final String str) throws IOException {
112:                synchronized (lock) {
113:                    out.write(str);
114:                    echo.write(str);
115:                }
116:            }
117:
118:            /**
119:             * Write a portion of a string.
120:             *
121:             * @param  str  A String
122:             * @param  off  Offset from which to start writing characters
123:             * @param  len  Number of characters to write
124:             * @throws IOException  If an I/O error occurs
125:             */
126:            public void write(final String str, final int off, final int len)
127:                    throws IOException {
128:                synchronized (lock) {
129:                    out.write(str, off, len);
130:                    echo.write(str, off, len);
131:                }
132:            }
133:
134:            /**
135:             * Flush both streams.
136:             *
137:             * @throws  IOException  If an I/O error occurs
138:             */
139:            public void flush() throws IOException {
140:                synchronized (lock) {
141:                    out.flush();
142:                    echo.flush();
143:                }
144:            }
145:
146:            /**
147:             * Close the main stream, If this object has been constructed with the
148:             * {@linkplain #EchoWriter(Writer) one argument constructor} (i.e.
149:             * if the echo stream is the {@linkplain System#out standard output}),
150:             * then the echo stream will not be closed. Otherwise it will be closed too.
151:             *
152:             * @throws  IOException  If an I/O error occurs
153:             */
154:            public void close() throws IOException {
155:                synchronized (lock) {
156:                    out.close();
157:                    echo.close(); // Overridden with an uncloseable version for System.out.
158:                }
159:            }
160:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.