Changeset 4009


Ignore:
Timestamp:
Nov 27, 2007, 2:39:50 PM (14 years ago)
Author:
Nicklas Nordborg
Message:

References #822: Create a separate WS-client dist

Use Apache commons-io to copy files instead of own code.

Location:
trunk
Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/examples/webservices/src/net/sf/basedb/ws/example/Main.java

    r3984 r4009  
    3131
    3232import org.apache.axis2.AxisFault;
     33import org.apache.commons.io.IOUtils;
    3334
    3435import net.sf.basedb.info.DataFileTypeInfo;
     
    270271            InputStream in = rc.downloadRawDataByType(info.getId(), fileType.getExternalId());
    271272            OutputStream out = new FileOutputStream(downloadTo);
    272             copy(in, out);
     273            IOUtils.copy(in, out);
    273274            out.close();
    274275            in.close();
     
    282283        System.out.println("");
    283284      }
    284     }
    285   }
    286  
    287   /**
    288     Copy from InputStream to OutputStream
    289   */
    290   public long copy(InputStream in, OutputStream out)
    291     throws IOException
    292   {
    293     int bytes = 0;
    294     long totalBytes = 0;
    295     byte[] buffer = new byte[1024];
    296     while (bytes != -1) // -1 = end of stream
    297     {
    298       bytes = in.read(buffer, 0, buffer.length);
    299       if (bytes > 0)
    300       {
    301         totalBytes += bytes;
    302         out.write(buffer, 0, bytes);
    303       }
    304     }
    305     return totalBytes;
    306   }
    307 
     285    }
     286  }
    308287 
    309288}
Note: See TracChangeset for help on using the changeset viewer.