~ubuntu-branches/ubuntu/oneiric/libpgjava/oneiric

« back to all changes in this revision

Viewing changes to src/interfaces/jdbc/org/postgresql/largeobject/BlobOutputStream.java

  • Committer: Bazaar Package Importer
  • Author(s): Arnaud Vandyck
  • Date: 2005-04-21 14:25:11 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20050421142511-wibh5vc31fkrorx7
Tags: 7.4.7-3
Built with sources...

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*-------------------------------------------------------------------------
 
2
 *
 
3
 * BlobOutputStream.java
 
4
 *     This implements a basic output stream that writes to a LargeObject
 
5
 *
 
6
 * Copyright (c) 2003, PostgreSQL Global Development Group
 
7
 *
 
8
 * IDENTIFICATION
 
9
 *        $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/largeobject/Attic/BlobOutputStream.java,v 1.6 2003/03/07 18:39:45 barry Exp $
 
10
 *
 
11
 *-------------------------------------------------------------------------
 
12
 */
1
13
package org.postgresql.largeobject;
2
14
 
3
15
import java.io.IOException;
4
16
import java.io.OutputStream;
5
17
import java.sql.SQLException;
6
18
 
7
 
/*
8
 
 * This implements a basic output stream that writes to a LargeObject
9
 
 */
10
19
public class BlobOutputStream extends OutputStream
11
20
{
12
21
        /*
68
77
                }
69
78
        }
70
79
 
 
80
        public void write(byte[] buf, int off, int len) throws java.io.IOException
 
81
        {
 
82
                try
 
83
                        {
 
84
                                // If we have any internally buffered data, send it first
 
85
                                if ( bpos > 0 )
 
86
                                        flush();
 
87
 
 
88
                                if ( off == 0 && len == buf.length )
 
89
                                        lo.write(buf); // save a buffer creation and copy since full buffer written
 
90
                                else
 
91
                                        lo.write(buf,off,len);
 
92
                        }
 
93
                catch (SQLException se)
 
94
                        {
 
95
                                throw new IOException(se.toString());
 
96
                        }
 
97
        }
 
98
 
 
99
 
71
100
        /*
72
101
         * Flushes this output stream and forces any buffered output bytes
73
102
         * to be written out. The general contract of <code>flush</code> is