java hostwrite_Java IOUtils.write方法代碼示例
本文整理匯總了Java中org.apache.commons.io.IOUtils.write方法的典型用法代碼示例。如果您正苦於以下問題:Java IOUtils.write方法的具體用法?Java IOUtils.write怎麽用?Java IOUtils.write使用的例子?那麽恭喜您, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.io.IOUtils的用法示例。
在下文中一共展示了IOUtils.write方法的19個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼示例。
示例1: save
點讚 5
import org.apache.commons.io.IOUtils; //導入方法依賴的package包/類
private Configuration save()
{
try
{
if(json.entrySet().size() == 0)
{
if(this.file.exists())
{
this.file.delete();
}
}
else
{
if(!this.file.exists())
{
this.file.createNewFile();
}
IOUtils.write(json.toString(), new FileOutputStream(this.file), "UTF-8");
}
}
catch(Exception e)
{
e.printStackTrace();
}
return this;
}
開發者ID:timmyrs,項目名稱:SuprDiscordBot,代碼行數:27,
示例2: code
點讚 4
import org.apache.commons.io.IOUtils; //導入方法依賴的package包/類
/**
* 生成代碼
*/
@RequestMapping("/code")
@RequiresPermissions("sys:generator:code")
public void code(HttpServletRequest request, HttpServletResponse response) throws IOException{
String[] tableNames = new String[]{};
//獲取表名,不進行xss過濾
HttpServletRequest orgRequest = XssHttpServletRequestWrapper.getOrgRequest(request);
String tables = orgRequest.getParameter("tables");
tableNames = JSON.parseArray(tables).toArray(tableNames);
byte[] data = sysGeneratorService.generatorCode(tableNames);
response.reset();
response.setHeader("Content-Disposition", "attachment; filename=\"renren.zip\"");
response.addHeader("Content-Length", "" + data.length);
response.setContentType("application/octet-stream; charset=UTF-8");
IOUtils.write(data, response.getOutputStream());
}
開發者ID:guolf,項目名稱:pds,代碼行數:22,
示例3: write
點讚 4
import org.apache.commons.io.IOUtils; //導入方法依賴的package包/類
@Override
public void write(final Collection collection, final Local file) throws AccessDeniedException {
final NSArray list = new NSArray(collection.size());
int i = 0;
for(S bookmark : collection) {
list.setValue(i, bookmark.serialize(SerializerFactory.get()));
i++;
}
final String content = list.toXMLPropertyList();
final OutputStream out = file.getOutputStream(false);
try {
IOUtils.write(content, out, Charset.forName("UTF-8"));
}
catch(IOException e) {
throw new AccessDeniedException(String.format("Cannot create file %s", file.getAbsolute()), e);
}
finally {
IOUtils.closeQuietly(out);
}
}
開發者ID:iterate-ch,項目名稱:cyberduck,代碼行數:21,
示例4: writeResponseResult
點讚 3
import org.apache.commons.io.IOUtils; //導入方法依賴的package包/類
@Override
protected void writeResponseResult(HttpServletRequest request, HttpServletResponse response) throws Exception {
Set classNames = CachedIntrospector.getClassNames();
StringBuilder sb = new StringBuilder();
for (String className : classNames) {
sb.append(".")
.append(className.replaceAll("\\.", "-"))
.append("-16")
.append(" {background-image:url(")
.append("../../admin/services/database_objects.GetIcon?className=")
.append(className)
.append(") !important;")
.append("}\r\n");
}
response.setContentType(MimeType.Css.value());
IOUtils.write(sb.toString(), response.getOutputStream(), "UTF-8");
}
開發者ID:convertigo,項目名稱:convertigo-engine,代碼行數:20,
示例5: create
點讚 3
import org.apache.commons.io.IOUtils; //導入方法依賴的package包/類
public Payment create(Payment payment) {
try {
HttpURLConnection con = getConnection("/payments");
con.setRequestMethod("POST");
con.setDoOutput(true);
con.setRequestProperty("Content-Type", "application/json");
String json = JsonUtils.toJson(payment);
IOUtils.write(json, con.getOutputStream(), "utf-8");
int status = con.getResponseCode();
if (status != 200) {
throw new RuntimeException("status code was " + status);
}
String content = IOUtils.toString(con.getInputStream(), "utf-8");
return JsonUtils.fromJson(content, Payment.class);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
開發者ID:intuit,項目名稱:karate,代碼行數:19,
示例6: download
點讚 3
import org.apache.commons.io.IOUtils; //導入方法依賴的package包/類
/**
* 從hadoop中下載文件
*
* @param taskName
* @param filePath
*/
public static void download(String taskName, String filePath, boolean existDelete) {
File file = new File(filePath);
if (file.exists()) {
if (existDelete) {
file.deleteOnExit();
} else {
return;
}
}
String hadoopAddress = propertyConfig.getProperty("sqoop.task." + taskName + ".tolink.linkConfig.uri");
String itemmodels = propertyConfig.getProperty("sqoop.task." + taskName + ".recommend.itemmodels");
try {
DistributedFileSystem distributedFileSystem = distributedFileSystem(hadoopAddress);
FSDataInputStream fsDataInputStream = distributedFileSystem.open(new Path(itemmodels));
byte[] bs = new byte[fsDataInputStream.available()];
fsDataInputStream.read(bs);
log.info(new String(bs));
FileOutputStream fileOutputStream = new FileOutputStream(new File(filePath));
IOUtils.write(bs, fileOutputStream);
IOUtils.closeQuietly(fileOutputStream);
} catch (IOException e) {
log.error(e);
}
}
開發者ID:babymm,項目名稱:mmsns,代碼行數:32,
示例7: write
點讚 3
import org.apache.commons.io.IOUtils; //導入方法依賴的package包/類
@Override
public void write(List items) throws IOException{
if(StringUtils.isBlank(path)){
return;
}
StringBuilder msg=new StringBuilder();
for(MessageItem item:items){
msg.append(item.toHtml());
}
String fullPath=path+"/urule-debug.html";
StringBuilder sb=new StringBuilder();
sb.append("
URule調試日誌信息");
sb.append(msg.toString());
sb.append("");
FileOutputStream out=new FileOutputStream(new File(fullPath));
IOUtils.write(sb.toString(), out);
out.flush();
out.close();
}
開發者ID:youseries,項目名稱:urule,代碼行數:20,
示例8: testReadRangeUnknownLength
點讚 3
import org.apache.commons.io.IOUtils; //導入方法依賴的package包/類
@Test
public void testReadRangeUnknownLength() throws Exception {
final B2Session session = new B2Session(
new Host(new B2Protocol(), new B2Protocol().getDefaultHostname(),
new Credentials(
System.getProperties().getProperty("b2.user"), System.getProperties().getProperty("b2.key")
)));
session.open(new DisabledHostKeyCallback(), new DisabledLoginCallback());
session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
final Path bucket = new Path("test-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
final Path test = new Path(bucket, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file));
new B2TouchFeature(session).touch(test, new TransferStatus());
final Local local = new Local(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString());
final byte[] content = RandomUtils.nextBytes(1000);
final OutputStream out = local.getOutputStream(false);
assertNotNull(out);
IOUtils.write(content, out);
out.close();
new B2SingleUploadService(new B2WriteFeature(session)).upload(
test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledStreamListener(),
new TransferStatus().length(content.length),
new DisabledConnectionCallback());
final TransferStatus status = new TransferStatus();
status.setLength(-1L);
status.setAppend(true);
status.setOffset(100L);
final InputStream in = new B2ReadFeature(session).read(test, status, new DisabledConnectionCallback());
assertNotNull(in);
final ByteArrayOutputStream buffer = new ByteArrayOutputStream(content.length - 100);
new StreamCopier(status, status).transfer(in, buffer);
final byte[] reference = new byte[content.length - 100];
System.arraycopy(content, 100, reference, 0, content.length - 100);
assertArrayEquals(reference, buffer.toByteArray());
in.close();
new B2DeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
session.close();
}
開發者ID:iterate-ch,項目名稱:cyberduck,代碼行數:40,
示例9: toJson
點讚 3
import org.apache.commons.io.IOUtils; //導入方法依賴的package包/類
@Override
public void toJson(final OutputStream out, final T object) {
try (StringWriter writer = new StringWriter()) {
this.objectMapper.writer(this.prettyPrinter).writeValue(writer, object);
final String hjsonString = JsonValue.readHjson(writer.toString()).toString(Stringify.HJSON);
IOUtils.write(hjsonString, out);
} catch (final Exception e) {
throw new IllegalArgumentException(e);
}
}
開發者ID:hsj-xiaokang,項目名稱:springboot-shiro-cas-mybatis,代碼行數:11,
示例10: testReadRange
點讚 3
import org.apache.commons.io.IOUtils; //導入方法依賴的package包/類
@Test
public void testReadRange() throws Exception {
final Host host = new Host(new DAVProtocol(), "test.cyberduck.ch", new Credentials(
System.getProperties().getProperty("webdav.user"), System.getProperties().getProperty("webdav.password")
));
host.setDefaultPath("/dav/basic");
final DAVSession session = new DAVSession(host);
session.open(new DisabledHostKeyCallback(), new DisabledLoginCallback());
session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
final Path test = new Path(new DefaultHomeFinderService(session).find(), UUID.randomUUID().toString(), EnumSet.of(Path.Type.file));
session.getFeature(Touch.class).touch(test, new TransferStatus());
final Local local = new Local(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString());
final byte[] content = new RandomStringGenerator.Builder().build().generate(1000).getBytes();
final OutputStream out = local.getOutputStream(false);
assertNotNull(out);
IOUtils.write(content, out);
out.close();
new DAVUploadFeature(new DAVWriteFeature(session)).upload(
test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledStreamListener(),
new TransferStatus().length(content.length),
new DisabledConnectionCallback());
final TransferStatus status = new TransferStatus();
status.setLength(content.length);
status.setAppend(true);
status.setOffset(100L);
final InputStream in = new DAVReadFeature(session).read(test, status.length(content.length - 100), new DisabledConnectionCallback());
assertNotNull(in);
final ByteArrayOutputStream buffer = new ByteArrayOutputStream(content.length - 100);
new StreamCopier(status, status).transfer(in, buffer);
final byte[] reference = new byte[content.length - 100];
System.arraycopy(content, 100, reference, 0, content.length - 100);
assertArrayEquals(reference, buffer.toByteArray());
in.close();
new DAVDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
session.close();
}
開發者ID:iterate-ch,項目名稱:cyberduck,代碼行數:38,
示例11: testReadRange
點讚 3
import org.apache.commons.io.IOUtils; //導入方法依賴的package包/類
@Test
public void testReadRange() throws Exception {
final Path drive = new OneDriveHomeFinderFeature(session).find();
final Path test = new Path(drive, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
new OneDriveTouchFeature(session).touch(test, new TransferStatus());
final Local local = new Local(System.getProperty("java.io.tmpdir"), new AlphanumericRandomStringService().random());
final byte[] content = RandomUtils.nextBytes(1000);
final OutputStream out = local.getOutputStream(false);
assertNotNull(out);
IOUtils.write(content, out);
out.close();
new DefaultUploadFeature(new OneDriveWriteFeature(session)).upload(
test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledStreamListener(),
new TransferStatus().length(content.length),
new DisabledConnectionCallback());
final TransferStatus status = new TransferStatus();
status.setLength(content.length);
status.setAppend(true);
status.setOffset(100L);
final OneDriveReadFeature read = new OneDriveReadFeature(session);
assertTrue(read.offset(test));
final InputStream in = read.read(test, status.length(content.length - 100), new DisabledConnectionCallback());
assertNotNull(in);
final ByteArrayOutputStream buffer = new ByteArrayOutputStream(content.length - 100);
new StreamCopier(status, status).transfer(in, buffer);
final byte[] reference = new byte[content.length - 100];
System.arraycopy(content, 100, reference, 0, content.length - 100);
assertArrayEquals(reference, buffer.toByteArray());
in.close();
new OneDriveDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
開發者ID:iterate-ch,項目名稱:cyberduck,代碼行數:33,
示例12: testInterruptStatus
點讚 3
import org.apache.commons.io.IOUtils; //導入方法依賴的package包/類
@Test
public void testInterruptStatus() throws Exception {
final ProtocolFactory factory = new ProtocolFactory(new HashSet<>(Collections.singleton(new IRODSProtocol())));
final Profile profile = new ProfilePlistReader(factory).read(
new Local("../profiles/iRODS (iPlant Collaborative).cyberduckprofile"));
final Host host = new Host(profile, profile.getDefaultHostname(), new Credentials(
System.getProperties().getProperty("irods.key"), System.getProperties().getProperty("irods.secret")
));
final IRODSSession session = new IRODSSession(host);
session.open(new DisabledHostKeyCallback(), new DisabledLoginCallback());
session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
final Local local = new Local(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString());
final int length = 32770;
final byte[] content = RandomUtils.nextBytes(length);
final OutputStream out = local.getOutputStream(false);
IOUtils.write(content, out);
out.close();
final Path test = new Path(new IRODSHomeFinderService(session).find(), UUID.randomUUID().toString(), EnumSet.of(Path.Type.file));
final TransferStatus status = new TransferStatus().length(content.length);
final Checksum checksum = new IRODSUploadFeature(session).upload(
test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledStreamListener() {
@Override
public void sent(final long bytes) {
super.sent(bytes);
status.setCanceled();
}
},
status,
new DisabledConnectionCallback());
assertTrue(status.isCanceled());
assertFalse(status.isComplete());
session.close();
}
開發者ID:iterate-ch,項目名稱:cyberduck,代碼行數:35,
示例13: put
點讚 3
import org.apache.commons.io.IOUtils; //導入方法依賴的package包/類
public void put(String key, V value) {
try (OutputStream os = fs.create(makePath(key))) {
IOUtils.write(config.getSerializer().serialize(value), os);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
開發者ID:skhalifa,項目名稱:QDrill,代碼行數:8,
示例14: extract
點讚 2
import org.apache.commons.io.IOUtils; //導入方法依賴的package包/類
public void extract(File dir ) throws IOException {
File listDir[] = dir.listFiles();
if (listDir.length!=0){
for (File i:listDir){
/* Warning! this will try and extract all files in the directory
if other files exist, a for loop needs to go here to check that
the file (i) is an archive file before proceeding */
if (i.isDirectory()){
break;
}
String fileName = i.toString();
String tarFileName = fileName +".tar";
FileInputStream instream= new FileInputStream(fileName);
GZIPInputStream ginstream =new GZIPInputStream(instream);
FileOutputStream outstream = new FileOutputStream(tarFileName);
byte[] buf = new byte[1024];
int len;
while ((len = ginstream.read(buf)) > 0)
{
outstream.write(buf, 0, len);
}
ginstream.close();
outstream.close();
//There should now be tar files in the directory
//extract specific files from tar
TarArchiveInputStream myTarFile=new TarArchiveInputStream(new FileInputStream(tarFileName));
TarArchiveEntry entry = null;
int offset;
FileOutputStream outputFile=null;
//read every single entry in TAR file
while ((entry = myTarFile.getNextTarEntry()) != null) {
//the following two lines remove the .tar.gz extension for the folder name
fileName = i.getName().substring(0, i.getName().lastIndexOf('.'));
fileName = fileName.substring(0, fileName.lastIndexOf('.'));
File outputDir = new File(i.getParent() + "/" + fileName + "/" + entry.getName());
if(! outputDir.getParentFile().exists()){
outputDir.getParentFile().mkdirs();
}
//if the entry in the tar is a directory, it needs to be created, only files can be extracted
if(entry.isDirectory()){
outputDir.mkdirs();
}else{
byte[] content = new byte[(int) entry.getSize()];
offset=0;
myTarFile.read(content, offset, content.length - offset);
outputFile=new FileOutputStream(outputDir);
IOUtils.write(content,outputFile);
outputFile.close();
}
}
//close and delete the tar files, leaving the original .tar.gz and the extracted folders
myTarFile.close();
File tarFile = new File(tarFileName);
tarFile.delete();
}
}
}
開發者ID:SamaGames,項目名稱:Hydroangeas,代碼行數:58,
示例15: sendEvent
點讚 2
import org.apache.commons.io.IOUtils; //導入方法依賴的package包/類
private void sendEvent(Socket socket, String content, String encoding) throws IOException {
OutputStream output = socket.getOutputStream();
IOUtils.write(content + IOUtils.LINE_SEPARATOR_UNIX, output, encoding);
output.flush();
}
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:6,
示例16: testAppendSecondPart
點讚 2
import org.apache.commons.io.IOUtils; //導入方法依賴的package包/類
@Test
public void testAppendSecondPart() throws Exception {
final SwiftSession session = new SwiftSession(
new Host(new SwiftProtocol(), "identity.api.rackspacecloud.com",
new Credentials(
System.getProperties().getProperty("rackspace.key"), System.getProperties().getProperty("rackspace.secret"))));
session.open(new DisabledHostKeyCallback(), new DisabledLoginCallback());
session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
final Path container = new Path("test.cyberduck.ch", EnumSet.of(Path.Type.directory, Path.Type.volume));
container.attributes().setRegion("DFW");
final Path test = new Path(container, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file));
final String name = UUID.randomUUID().toString();
final Local local = new Local(System.getProperty("java.io.tmpdir"), name);
final int length = 2 * 1024 * 1024;
final byte[] content = RandomUtils.nextBytes(length);
IOUtils.write(content, local.getOutputStream(false));
final TransferStatus status = new TransferStatus();
status.setLength(content.length);
final AtomicBoolean interrupt = new AtomicBoolean();
try {
new SwiftLargeObjectUploadFeature(session, new SwiftRegionService(session), new SwiftWriteFeature(session, new SwiftRegionService(session)),
1024L * 1024L, 1).upload(test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledStreamListener() {
long count;
@Override
public void sent(final long bytes) {
count += bytes;
if(count >= 1.1 * 1024L * 1024L) {
throw new RuntimeException();
}
}
}, status, new DisabledLoginCallback());
}
catch(BackgroundException e) {
// Expected
interrupt.set(true);
}
assertTrue(interrupt.get());
assertEquals(1024L * 1024L, status.getOffset(), 0L);
assertFalse(status.isComplete());
final TransferStatus append = new TransferStatus().append(true).length(1024L * 1024L).skip(1024L * 1024L);
new SwiftLargeObjectUploadFeature(session, new SwiftRegionService(session), new SwiftWriteFeature(session, new SwiftRegionService(session)),
1024L * 1024L, 1).upload(test, local,
new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledStreamListener(), append,
new DisabledLoginCallback());
assertEquals(2 * 1024L * 1024L, append.getOffset(), 0L);
assertTrue(append.isComplete());
assertTrue(new SwiftFindFeature(session).find(test));
assertEquals(2 * 1024L * 1024L, new SwiftAttributesFinderFeature(session).find(test).getSize(), 0L);
final byte[] buffer = new byte[content.length];
final InputStream in = new SwiftReadFeature(session, new SwiftRegionService(session)).read(test, new TransferStatus(), new DisabledConnectionCallback());
IOUtils.readFully(in, buffer);
in.close();
assertArrayEquals(content, buffer);
new SwiftDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
local.delete();
session.close();
}
開發者ID:iterate-ch,項目名稱:cyberduck,代碼行數:60,
示例17: exportData
點讚 2
import org.apache.commons.io.IOUtils; //導入方法依賴的package包/類
/**
* 導出數據
* @param builder
* @param labelsSupplier
* @param contentSupplier
* @param out 經過分詞器的輸出流
*/
protected void exportData(QueryBuilder builder, Function>> labelsSupplier,
Function> contentSupplier, OutputStream out) {
final int size = 50;
String scrollId = null;
int page = 1;
while(true) {
LOG.debug("正在輸出第" + page + "頁,query:" + builder);
SearchResponse response;
if(StringUtils.isBlank(scrollId)) {
response = search().setQuery(builder).setSize(size)
.setScroll(SCROLL_TIMEOUT).get();
scrollId = response.getScrollId();
} else {
response = client.prepareSearchScroll(scrollId)
.setScroll(SCROLL_TIMEOUT).get();
}
final List> labels = labelsSupplier.apply(response);
final List contentList = contentSupplier.apply(response);
Preconditions.checkNotNull(labels);
Preconditions.checkNotNull(contentList);
if(contentList.size()<=0)
break;
//開始分詞
List combine;
if(labels.size() > 0) {
combine = labels.stream().map(list -> list.parallelStream().collect(Collectors.joining("/")))
.collect(Collectors.toList());
for(int i = 0;i
combine.set(i, combine.get(i) + " " + contentList.get(i));
} else
combine = contentList;
page++;
try {
IOUtils.write(combine.stream().collect(Collectors.joining("\n")) + "\n", out, "utf-8");
out.flush();
} catch(IOException e) {
LOG.error("文件寫出錯誤, 由於 " + e.getLocalizedMessage());
}
}
}
開發者ID:TransientBuckwheat,項目名稱:nest-spider,代碼行數:48,
示例18: testUploadWithBulk
點讚 2
import org.apache.commons.io.IOUtils; //導入方法依賴的package包/類
@Test
public void testUploadWithBulk() throws Exception {
// 5L * 1024L * 1024L
final Host host = new Host(new B2Protocol(), new B2Protocol().getDefaultHostname(),
new Credentials(
System.getProperties().getProperty("b2.user"), System.getProperties().getProperty("b2.key")
));
final B2Session session = new B2Session(host);
session.open(new DisabledHostKeyCallback(), new DisabledLoginCallback());
session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
final Path home = new Path("/test-cyberduck", EnumSet.of(Path.Type.volume, Path.Type.directory));
final CryptoVault cryptomator = new CryptoVault(
new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new DisabledPasswordStore());
final Path vault = cryptomator.create(session, null, new VaultCredentials("test"));
final Path test = new Path(vault, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
session.withRegistry(new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator));
final TransferStatus writeStatus = new TransferStatus();
final int length = 5242885;
final byte[] content = RandomUtils.nextBytes(length);
writeStatus.setLength(content.length);
final CryptoBulkFeature bulk = new CryptoBulkFeature<>(session, new DisabledBulkFeature(), new B2DeleteFeature(session), cryptomator);
bulk.pre(Transfer.Type.upload, Collections.singletonMap(test, writeStatus), new DisabledConnectionCallback());
final CryptoUploadFeature m = new CryptoUploadFeature<>(session,
new B2LargeUploadService(session, new B2WriteFeature(session), 5242880L, 5),
new B2WriteFeature(session), cryptomator);
final Local local = new Local(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString());
IOUtils.write(content, local.getOutputStream(false));
m.upload(test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledStreamListener(), writeStatus, null);
assertEquals((long) content.length, writeStatus.getOffset(), 0L);
assertTrue(writeStatus.isComplete());
assertTrue(new CryptoFindFeature(session, new B2FindFeature(session), cryptomator).find(test));
assertEquals(content.length, new CryptoAttributesFeature(session, new B2AttributesFinderFeature(session), cryptomator).find(test).getSize());
final ByteArrayOutputStream buffer = new ByteArrayOutputStream(content.length);
final TransferStatus readStatus = new TransferStatus().length(content.length);
final InputStream in = new CryptoReadFeature(session, new B2ReadFeature(session), cryptomator).read(test, readStatus, new DisabledConnectionCallback());
new StreamCopier(readStatus, readStatus).transfer(in, buffer);
assertArrayEquals(content, buffer.toByteArray());
new CryptoDeleteFeature(session, new B2DeleteFeature(session), cryptomator).delete(Arrays.asList(test, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
local.delete();
session.close();
}
開發者ID:iterate-ch,項目名稱:cyberduck,代碼行數:42,
示例19: writeResource
點讚 1
import org.apache.commons.io.IOUtils; //導入方法依賴的package包/類
/**
* Write on a resource.
* @param resource the resource to write on.
* @param string the string to write.
* @throws IOException when resource cannot be read.
*/
public static void writeResource(String resource, String string) throws IOException {
try (final OutputStream out = getOutputStream(resource)) {
IOUtils.write(string, out, Charset.defaultCharset());
}
}
開發者ID:braineering,項目名稱:ares,代碼行數:12,
注:本文中的org.apache.commons.io.IOUtils.write方法示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。
java hostwrite_Java IOUtils.write方法代碼示例相关推荐
- java servicefactory_Java DirectoryServiceFactory.getDirectoryService方法代碼示例
本文整理匯總了Java中org.apache.directory.server.core.factory.DirectoryServiceFactory.getDirectoryService方法的典 ...
- java getstringarray_Java AnnotationAttributes.getStringArray方法代碼示例
本文整理匯總了Java中org.springframework.core.annotation.AnnotationAttributes.getStringArray方法的典型用法代碼示例.如果您正苦 ...
- java getselecteditem_Java JComboBox.getSelectedItem方法代碼示例
本文整理匯總了Java中javax.swing.JComboBox.getSelectedItem方法的典型用法代碼示例.如果您正苦於以下問題:Java JComboBox.getSelectedIt ...
- java setlocation_Java Point.setLocation方法代碼示例
本文整理匯總了Java中java.awt.Point.setLocation方法的典型用法代碼示例.如果您正苦於以下問題:Java Point.setLocation方法的具體用法?Java Poin ...
- java setpriority_Java TaskEntity.setPriority方法代碼示例
本文整理匯總了Java中org.activiti.engine.impl.persistence.entity.TaskEntity.setPriority方法的典型用法代碼示例.如果您正苦於以下問題 ...
- java importgeopoint_Java GeoPoint.project方法代碼示例
本文整理匯總了Java中com.nextgis.maplib.datasource.GeoPoint.project方法的典型用法代碼示例.如果您正苦於以下問題:Java GeoPoint.proje ...
- java hssffont_Java HSSFFont.setColor方法代碼示例
本文整理匯總了Java中org.apache.poi.hssf.usermodel.HSSFFont.setColor方法的典型用法代碼示例.如果您正苦於以下問題:Java HSSFFont.setC ...
- java disconnect_Java BlockingConnection.disconnect方法代碼示例
本文整理匯總了Java中org.fusesource.mqtt.client.BlockingConnection.disconnect方法的典型用法代碼示例.如果您正苦於以下問題:Java Bloc ...
- java dofinal_Java Mac.doFinal方法代碼示例
本文整理匯總了Java中javax.crypto.Mac.doFinal方法的典型用法代碼示例.如果您正苦於以下問題:Java Mac.doFinal方法的具體用法?Java Mac.doFinal怎 ...
- java proertyutils_Java IFile.exists方法代碼示例
本文整理匯總了Java中org.eclipse.core.resources.IFile.exists方法的典型用法代碼示例.如果您正苦於以下問題:Java IFile.exists方法的具體用法?J ...
最新文章
- 使用 NLTK 对文本进行清洗,索引工具
- java自带的resize方法_java对图片进行压缩和resize缩放的方法
- 深入Android 【一】 —— 序及开篇
- .Net Core with 微服务 - 可靠消息最终一致性分布式事务
- Ubuntu系统下载地址(Ubuntu、ISO、Ubuntu下载)
- CSDN 七夕包分配,最后一天啦!
- android连接指定的wifi
- 如何恢复Mac上已删除的文件?
- 领域搜索算法 是什么 和遗传算法、模拟退火算法、禁忌搜索算法、模糊优化 算法、微粒群算法关系
- java类Writer和类Reader小结
- 计算机网络实验指导书 pdf,《计算机网络》实验指导书.pdf
- VSCode python 中文乱码
- sklearn学习之LR算法实践
- IOS逆向-LLVM、代码混淆
- 手机照片分辨率dpi怎么调?一寸证件照照片dpi怎么调300?
- redis 中pipline,mset, mget使用对比
- 【每日一题】一起冲击蓝桥杯吧——Day07【蓝桥真题一起练】
- [朴智妍][또르르][轱辘轱辘]
- exsi rh2288hv5 驱动_华为RH2288H V5服务器windows 2012阵列卡驱动
- 对话哈佛大学教授Lukin:量子计算将在我们有生之年普及! | AI英雄