added copy methods
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
gradle.version = 7.4.1
|
gradle.version = 7.4.1
|
||||||
jwo.version=1.0-SNAPSHOT
|
jwo.version=1.0-SNAPSHOT
|
||||||
junitJupiter.version=5.7.0
|
junitJupiter.version=5.8.2
|
||||||
lombok.version=1.18.22
|
lombok.version=1.18.22
|
||||||
slf4j.version=1.7.32
|
slf4j.version=1.7.32
|
||||||
guice.version = 5.0.1
|
guice.version = 5.0.1
|
||||||
|
@@ -585,4 +585,23 @@ public class JWO {
|
|||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
|
public static void copy(InputStream is, OutputStream os, byte[] buffer) {
|
||||||
|
while(true) {
|
||||||
|
int read = is.read(buffer);
|
||||||
|
if(read < 0) break;
|
||||||
|
os.write(buffer, 0, read);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void copy(InputStream is, OutputStream os, int bufferSize) {
|
||||||
|
byte[] buffer = new byte[bufferSize];
|
||||||
|
copy(is, os, buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void copy(InputStream is, OutputStream os) {
|
||||||
|
byte[] buffer = new byte[0x10000];
|
||||||
|
copy(is, os, buffer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -22,7 +22,7 @@ public class PathClassLoaderTest {
|
|||||||
@Test
|
@Test
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
void test() {
|
void test() {
|
||||||
FileSystem fs = FileSystems.newFileSystem(testBundle, null);
|
FileSystem fs = FileSystems.newFileSystem(testBundle, (ClassLoader) null);
|
||||||
List<Path> paths = StreamSupport.stream(fs.getRootDirectories().spliterator(), false).flatMap(new Function<Path, Stream<Path>>() {
|
List<Path> paths = StreamSupport.stream(fs.getRootDirectories().spliterator(), false).flatMap(new Function<Path, Stream<Path>>() {
|
||||||
@Override
|
@Override
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
@@ -36,7 +36,7 @@ public class PathClassLoaderTest {
|
|||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public Stream<Path> apply(Path path) {
|
public Stream<Path> apply(Path path) {
|
||||||
System.out.println(path.getFileName().toString());
|
System.out.println(path.getFileName().toString());
|
||||||
return StreamSupport.stream(FileSystems.newFileSystem(path, null).getRootDirectories().spliterator(), false);
|
return StreamSupport.stream(FileSystems.newFileSystem(path, (ClassLoader) null).getRootDirectories().spliterator(), false);
|
||||||
}
|
}
|
||||||
}).collect(Collectors.toUnmodifiableList());
|
}).collect(Collectors.toUnmodifiableList());
|
||||||
PathClassLoader classLoader = new PathClassLoader(paths);
|
PathClassLoader classLoader = new PathClassLoader(paths);
|
||||||
|
Reference in New Issue
Block a user