Revision 3556 trunk/libraries/libGDBMS/src/main/java/com/hardcode/gdbms/driver/DriverUtilities.java
DriverUtilities.java | ||
---|---|---|
42 | 42 |
* +34 963163400 |
43 | 43 |
* dac@iver.es |
44 | 44 |
*/ |
45 |
|
|
46 |
/* CVS MESSAGES: |
|
47 |
* |
|
48 |
* $Id$ |
|
49 |
* $Log$ |
|
50 |
* Revision 1.2 2006-01-09 18:15:06 fjp |
|
51 |
* Solucionar un fallo detectado por Jaume que hac?a que no se escribieran archivos de m?s de 100 KBytes. |
|
52 |
* |
|
53 |
*/ |
|
45 | 54 |
package com.hardcode.gdbms.driver; |
46 | 55 |
|
47 | 56 |
import java.io.IOException; |
... | ... | |
62 | 71 |
*/ |
63 | 72 |
public static void copy(FileChannel fcin, FileChannel fcout) |
64 | 73 |
throws IOException { |
74 |
|
|
75 |
// Esto antes ten?a un problema de que solo copiaba |
|
76 |
// los primeros 100 KBytes. Ahora le hemos puesto |
|
77 |
// un while y hemos comprobado que copia todo el fichero. |
|
78 |
// Ole tus huevos Luis, que tenga que comentar esto |
|
79 |
// y ver c?mo est? el resto del c?digo. |
|
65 | 80 |
ByteBuffer buffer = ByteBuffer.allocate(102400); |
66 | 81 |
buffer.clear(); |
67 |
int r = fcin.read(buffer); |
|
68 |
if (r == -1) { |
|
69 |
return; |
|
82 |
int r = 0; |
|
83 |
int position = 0; |
|
84 |
while ((r = fcin.read(buffer, position)) != -1) |
|
85 |
{ |
|
86 |
buffer.flip(); |
|
87 |
int bytesWritten = fcout.write(buffer, position); |
|
88 |
position += bytesWritten; |
|
89 |
buffer.clear(); |
|
70 | 90 |
} |
71 |
buffer.flip(); |
|
72 |
fcout.write(buffer); |
|
73 | 91 |
} |
74 | 92 |
|
75 | 93 |
} |
Also available in: Unified diff