假设您有一个定义copyFile(String, String)方法的java类:public class FileSystem {
public static void copyFile(String sourcePath, String destinationPath)
throws IOException
{
// ignore the fact that I'm not properly managing resources...
FileInputStream source = new FileInputStream(sourcePath);
FileOutputStream destination = new FileOutputStream(destinationPath);
copyStream(source, destination);
source.close();
destination.close();
}
private static void copyStream(InputStream source, OutputStream destination)
throws IOException
{
byte[] buffer = new byte[1024];
int length;
while ( (length = source.read(buffer)) != -1 ) {
destination.write(buffer, 0, length);
}
}
}
假设您将其包装在Java存储过程中:
CREATE PROCEDURE copy