重新格式化所有java代码

This commit is contained in:
veryben
2017-05-19 09:56:24 +08:00
parent 69417006f4
commit 75931a8053
32 changed files with 7826 additions and 8880 deletions
@@ -1,61 +1,55 @@
package org.csource.fastdfs;
import java.io.IOException;
import java.io.OutputStream;
import java.io.InputStream;
import org.csource.fastdfs.UploadCallback;
import java.io.OutputStream;
/**
* Upload file by stream
* @author zhouzezhong & Happy Fish / YuQing
* @version Version 1.11
*/
public class UploadStream implements UploadCallback
{
private InputStream inputStream; //input stream for reading
private long fileSize = 0; //size of the uploaded file
/**
* constructor
* @param inputStream input stream for uploading
* @param fileSize size of uploaded file
*/
public UploadStream(InputStream inputStream, long fileSize)
{
super();
this.inputStream = inputStream;
this.fileSize = fileSize;
}
* Upload file by stream
*
* @author zhouzezhong & Happy Fish / YuQing
* @version Version 1.11
*/
public class UploadStream implements UploadCallback {
private InputStream inputStream; //input stream for reading
private long fileSize = 0; //size of the uploaded file
/**
* send file content callback function, be called only once when the file uploaded
* @param out output stream for writing file content
* @return 0 success, return none zero(errno) if fail
*/
public int send(OutputStream out) throws IOException
{
long remainBytes = fileSize;
byte[] buff = new byte[256 * 1024];
int bytes;
while(remainBytes > 0)
{
try
{
if ((bytes=inputStream.read(buff, 0, remainBytes > buff.length ? buff.length : (int)remainBytes)) < 0)
{
return -1;
}
}
catch(IOException ex)
{
ex.printStackTrace();
return -1;
}
out.write(buff, 0, bytes);
remainBytes -= bytes;
}
return 0;
}
/**
* constructor
*
* @param inputStream input stream for uploading
* @param fileSize size of uploaded file
*/
public UploadStream(InputStream inputStream, long fileSize) {
super();
this.inputStream = inputStream;
this.fileSize = fileSize;
}
/**
* send file content callback function, be called only once when the file uploaded
*
* @param out output stream for writing file content
* @return 0 success, return none zero(errno) if fail
*/
public int send(OutputStream out) throws IOException {
long remainBytes = fileSize;
byte[] buff = new byte[256 * 1024];
int bytes;
while (remainBytes > 0) {
try {
if ((bytes = inputStream.read(buff, 0, remainBytes > buff.length ? buff.length : (int) remainBytes)) < 0) {
return -1;
}
} catch (IOException ex) {
ex.printStackTrace();
return -1;
}
out.write(buff, 0, bytes);
remainBytes -= bytes;
}
return 0;
}
}