当前位置: 首页 > news >正文

沧县做网站价格jsp网站 自动发送邮件

沧县做网站价格,jsp网站 自动发送邮件,wordpress 网站图标设置方法,上海嘉定做网站公司Android端使用Samba连接共享文件夹#xff0c;下载或上传文件的功能实现。如果你是用jcifs工具包#xff0c;那么你要注意jcifs-ng 和 jcifs 支持的SMB版本区别。 JCIFS-NG的github地址 JCIFS官网地址 这里有关于jciffs、jcifs-codelibs、jcifs-ng、smbj的详细介绍 对比 支…Android端使用Samba连接共享文件夹下载或上传文件的功能实现。如果你是用jcifs工具包那么你要注意jcifs-ng 和 jcifs 支持的SMB版本区别。 JCIFS-NG的github地址 JCIFS官网地址 这里有关于jciffs、jcifs-codelibs、jcifs-ng、smbj的详细介绍 对比 支持的smb版本 jcifs 仅支持SMB 1.0CIFS jcifs 最初是针对 SMB 1.0CIFS协议开发的因此它是对 SMB 1.0 版本的最好支持。 jcifs-ng 2.1 此版本默认启用SMB2支持并包含一些实验性的SMB3.0支持。 协商的协议级别现在可以使用jcifs.smb.client.minVersion和jcifs.smb.client.maxVersion进行控制这会弃用jcifs.smb.client.enableSMB2/jcifs.sm b.client.disableSMB1属性。默认的最小/最大版本是SMB1到SMB210。 此版本禁止服务器浏览即服务器/工作组枚举并包含有关身份验证的一些突破性API更改。 jcifs-ng 2.0 此版本支持SMB22.02协议级别目前仅在配置了jcifs.smb.client.enableSMB2的情况下宣布支持SMB2但如果服务器不支持SMB1方言也可以选择支持SMB2。 开发状态 jcifs jcifs 是最初由 Mike Allen 开发的 Java CIFS 实现最后一个官方发布版本是 1.3.19发布于 2007 年。此后jcifs 进入了维护模式不再进行主要更新。 jcifs-ng jcifs-ngjcifs-next generation是基于 jcifs 的一个分支由 Alexander Böhm 等人开发。它是对 jcifs 的改进和扩展具有更现代化的代码结构和更多功能。jcifs-ng 目前仍在活跃地开发和维护。 功能和性能 jcifs-ng 在功能和性能上进行了改进和优化相比于原始的 jcifs它提供了更多的功能和更好的性能。例如jcifs-ng 支持更多的 SMB 协议特性并且在速度和稳定性方面进行了改进。 API 和使用方式 jcifs-ng 在 API 和使用方式上与 jcifs 类似但可能会有一些差异和改进。因此如果你已经熟悉 jcifs那么迁移到 jcifs-ng 应该相对容易。 这里使用的是jcifs-ng 2.1.9 添加依赖 implementation eu.agno3.jcifs:jcifs-ng:2.1.9代码实现Kotlin package com.xxx.customerimport android.util.Log import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.lifecycleScope import jcifs.CIFSContext import jcifs.context.SingletonContext import jcifs.smb.SmbException import jcifs.smb.SmbFile import jcifs.smb.SmbFileInputStream import jcifs.smb.SmbFileOutputStream import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import java.io.BufferedInputStream import java.io.BufferedOutputStream import java.io.File import java.io.FileInputStream import java.io.FileOutputStream import java.io.IOException import java.util.Propertiesclass SambaManager {private val SAMBA_SERVER_IP your server ipprivate val SAMBA_USERNAME usernameprivate val SAMBA_PASSWORD passwordcompanion object {private const val TAG SambaManagerprivate var mCIFSContext: CIFSContext? null}/*** 上传文件到共享文件夹指定目录* param viewLifecycleOwner* param localFilePathList 待上传的本地文件路径列表* param remoteFolderPath 要上传到的远端路径* 如果共享文件夹为shared_folder则该路径应该包含shared_folder* 如shared_folder/ 或 shared_folder/xxx* param onComplete 任务完成厚的回调*/fun uploadFiles(viewLifecycleOwner: LifecycleOwner,localFilePathList: MutableListString,remoteFolderPath: String,onComplete: (Int) - Unit) {viewLifecycleOwner.lifecycleScope.launch(Dispatchers.IO) {var count 0val smbContext getCIFSContext()for (filePath in localFilePathList) {val localFile File(filePath)if (!localFile.exists()) {continue}val folderUrl smb://${SAMBA_SERVER_IP}/${remoteFolderPath.trim(/)}val smbFolder try {SmbFile(folderUrl, smbContext)} catch (e: IOException) {Log.e(TAG, Failed to create SmbFile, e)continue}//创建目录smbFolder.mkdirs()val url $folderUrl/${localFile.name}val smbFile try {SmbFile(url, smbContext)} catch (e: IOException) {Log.e(TAG, Failed to create SmbFile, e)continue}try {if (smbFile.exists()) {smbFile.delete()}smbFile.createNewFile()} catch (e: SmbException) {Log.e(TAG, Failed to create new SmbFile, e)continue}try {val outputStream BufferedOutputStream(SmbFileOutputStream(smbFile))val inputStream BufferedInputStream(FileInputStream(localFile))inputStream.use { input -outputStream.use { output -val buffer ByteArray(1024)var bytesRead: Intwhile (input.read(buffer).also { bytesRead it } ! -1) {output.write(buffer, 0, bytesRead)}}}count} catch (e: IOException) {Log.e(TAG, Failed to download file, e)continue}}onComplete(count)}}/*** 批量下载文件* param viewLifecycleOwner* param remoteFilePathList 需要下载的远端文件路径列表* param localFolderPath 本地文件夹路径用于保存下载的文件* param onComplete 任务完成后的回调*/fun downloadFiles(viewLifecycleOwner: LifecycleOwner,remoteFilePathList: MutableListString,localFolderPath: String,onComplete: (Int) - Unit) {viewLifecycleOwner.lifecycleScope.launch(Dispatchers.IO) {var count 0val smbContext getCIFSContext()for (path in remoteFilePathList) {val strList path.split(/)var fileName strList[strList.lastIndex]val url smb://${SAMBA_SERVER_IP}/${path.trimStart(/)}val smbFile try {SmbFile(url, smbContext)} catch (e: IOException) {Log.e(TAG, Failed to create SmbFile, e)continue}if (!smbFile.exists()) {Log.e(TAG, File does not exist: ${path})continue}try {val localFile File($localFolderPath/$fileName)if (!localFile.exists()) {localFile.createNewFile()}val inputStream BufferedInputStream(SmbFileInputStream(smbFile))val outputStream BufferedOutputStream(FileOutputStream(localFile))inputStream.use { input -outputStream.use { output -val buffer ByteArray(1024)var bytesRead: Intwhile (input.read(buffer).also { bytesRead it } ! -1) {output.write(buffer, 0, bytesRead)}}}count} catch (e: IOException) {Log.e(TAG, Failed to download file, e)continue}}onComplete(count)}}/*** 获取包含配置参数的CIFSContext*/private fun getCIFSContext(): CIFSContext {if (mCIFSContext null) {val properties Properties()properties.setProperty(jcifs.smb.client.domain, SAMBA_SERVER_IP);properties.setProperty(jcifs.smb.client.username, SAMBA_USERNAME);properties.setProperty(jcifs.smb.client.password, SAMBA_PASSWORD);SingletonContext.init(properties) //init只能初始化一次mCIFSContext SingletonContext.getInstance()}return mCIFSContext!!} }
http://www.sczhlp.com/news/240473/

相关文章:

  • 网站后台费用临泽县建设局网站
  • seo建站技巧企业网站源码vue
  • 淄博网站外包网站pc开发上海
  • 小网站做长尾词还是流量词域名在线查询
  • 网站是做流程唐山网址建站
  • 浏览器网站免费进入建程网下载安装
  • 长春免费做网站做房产的一般用哪个网站好
  • 好的做网站的公司有哪些网页游戏排行榜 511
  • 办网站如何备案制作企业网站方案
  • 手机app微信网站小微企业管理软件
  • 怎么做网站界面设计医药网站建设需要注意点
  • 网站开发 erp系统开发微网站建设比较全面的是
  • 理聪网营销型网站建设网站主关键词如何优化
  • 大规模网站开发语言wordpress极简文章模板
  • 设备管理系统网站模板手机搜索引擎排行榜
  • 深圳做app网站设计wordpress 插件player
  • 学院网站的系统建设方式wordpress系统那个主题好用
  • 贵阳建站做网站上加入模块怎么加入
  • wordpress制作培训网站国家免费职业培训平台
  • 不会PS怎么建网站莱芜租房网站
  • 江苏两学一做网站西宁seo快速排名
  • 做网站拿来卖网站开发课程报告心得
  • 软件开发和网站建设那个好网站开发岗位职责
  • 做网站需要电脑吗上海市建设考核中心网站
  • 门户网站源码入驻dw网站根目录怎么做
  • 苏州市市政建设管理处网站浏览器怎么打开网站服务器设置
  • 网站制作多少钱啊万域网站建设
  • 做的网站怎么联网电子商务主要是做什么的
  • 网站数据库 数据库空间购买租用自媒体seo是什么意思
  • o2o苗木网站建设wordpress怎么给栏目添加tdk