Untitled
By: a guest | Mar 16th, 2010 | Syntax:
None | Size: 0.80 KB | Hits: 36 | Expires: Never
private static void fileDownload (Socket s, String t, String z) throws IOException {
BufferedOutputStream out = new BufferedOutputStream (s.getOutputStream());
File F = new File (rootPath.concat(t));
File [] lista = F.listFiles();
if (lista != null) {
for (int i = 0; i < lista.length; i++) {
if (lista[i].getName().equals(z)) {
File f = new File (rootPath.concat(t).concat("/").concat(z));
BufferedInputStream fin = new BufferedInputStream(new FileInputStream(f));
copia(fin, out, 10000);
}
}
}
}
public static void copia (InputStream in, OutputStream out, int bufferSize) throws IOException {
byte[] buffer = new byte[bufferSize];
int n;
while ((n = in.read(buffer)) > 0) {
out.write(buffer, 0, n);
}
}