• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Packet类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.trilead.ssh2.sftp.Packet的典型用法代码示例。如果您正苦于以下问题:Java Packet类的具体用法?Java Packet怎么用?Java Packet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Packet类属于com.trilead.ssh2.sftp包,在下文中一共展示了Packet类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: sendMessage

import com.trilead.ssh2.sftp.Packet; //导入依赖的package包/类
private final void sendMessage(int type, int requestId, byte[] msg, int off, int len) throws IOException
{
	int msglen = len + 1;

	if (type != Packet.SSH_FXP_INIT)
		msglen += 4;

	os.write(msglen >> 24);
	os.write(msglen >> 16);
	os.write(msglen >> 8);
	os.write(msglen);
	os.write(type);

	if (type != Packet.SSH_FXP_INIT)
	{
		os.write(requestId >> 24);
		os.write(requestId >> 16);
		os.write(requestId >> 8);
		os.write(requestId);
	}

	os.write(msg, off, len);
	os.flush();
}
 
开发者ID:dragonlinux,项目名称:connectbot,代码行数:25,代码来源:SFTPv3Client.java


示例2: setstat

import com.trilead.ssh2.sftp.Packet; //导入依赖的package包/类
/**
 *  Modify the attributes of a file. Used for operations such as changing
 *  the ownership, permissions or access times, as well as for truncating a file.
 * 
 * @param path See the {@link SFTPv3Client comment} for the class for more details.
 * @param attr A SFTPv3FileAttributes object. Specifies the modifications to be
 *             made to the attributes of the file. Empty fields will be ignored.
 * @throws IOException
 */
public void setstat(String path, SFTPv3FileAttributes attr) throws IOException
{
	int req_id = generateNextRequestID();

	TypesWriter tw = new TypesWriter();
	tw.writeString(path, charsetName);
	tw.writeBytes(createAttrs(attr));

	if (debug != null)
	{
		debug.println("Sending SSH_FXP_SETSTAT...");
		debug.flush();
	}

	sendMessage(Packet.SSH_FXP_SETSTAT, req_id, tw.getBytes());

	expectStatusOKMessage(req_id);
}
 
开发者ID:dragonlinux,项目名称:connectbot,代码行数:28,代码来源:SFTPv3Client.java


示例3: fsetstat

import com.trilead.ssh2.sftp.Packet; //导入依赖的package包/类
/**
 * 	Modify the attributes of a file. Used for operations such as changing
 *  the ownership, permissions or access times, as well as for truncating a file.
 * 
 * @param handle a SFTPv3FileHandle handle
 * @param attr A SFTPv3FileAttributes object. Specifies the modifications to be
 *             made to the attributes of the file. Empty fields will be ignored.
 * @throws IOException
 */
public void fsetstat(SFTPv3FileHandle handle, SFTPv3FileAttributes attr) throws IOException
{
	checkHandleValidAndOpen(handle);

	int req_id = generateNextRequestID();

	TypesWriter tw = new TypesWriter();
	tw.writeString(handle.fileHandle, 0, handle.fileHandle.length);
	tw.writeBytes(createAttrs(attr));

	if (debug != null)
	{
		debug.println("Sending SSH_FXP_FSETSTAT...");
		debug.flush();
	}

	sendMessage(Packet.SSH_FXP_FSETSTAT, req_id, tw.getBytes());

	expectStatusOKMessage(req_id);
}
 
开发者ID:dragonlinux,项目名称:connectbot,代码行数:30,代码来源:SFTPv3Client.java


示例4: createSymlink

import com.trilead.ssh2.sftp.Packet; //导入依赖的package包/类
/**
 * Create a symbolic link on the server. Creates a link "src" that points
 * to "target".
 * 
 * @param src See the {@link SFTPv3Client comment} for the class for more details.
 * @param target See the {@link SFTPv3Client comment} for the class for more details.
 * @throws IOException
 */
public void createSymlink(String src, String target) throws IOException
{
	int req_id = generateNextRequestID();

	/* Either I am too stupid to understand the SFTP draft
	 * or the OpenSSH guys changed the semantics of src and target.
	 */

	TypesWriter tw = new TypesWriter();
	tw.writeString(target, charsetName);
	tw.writeString(src, charsetName);

	if (debug != null)
	{
		debug.println("Sending SSH_FXP_SYMLINK...");
		debug.flush();
	}

	sendMessage(Packet.SSH_FXP_SYMLINK, req_id, tw.getBytes());

	expectStatusOKMessage(req_id);
}
 
开发者ID:dragonlinux,项目名称:connectbot,代码行数:31,代码来源:SFTPv3Client.java


示例5: createSymlink

import com.trilead.ssh2.sftp.Packet; //导入依赖的package包/类
/**
 * Create a symbolic link on the server. Creates a link "src" that points to
 * "target".
 * 
 * @param src
 *            See the {@link SFTPv3Client comment} for the class for more
 *            details.
 * @param target
 *            See the {@link SFTPv3Client comment} for the class for more
 *            details.
 * @throws IOException
 */
public void createSymlink(String src, String target) throws IOException {
	int req_id = generateNextRequestID();

	/*
	 * Either I am too stupid to understand the SFTP draft or the OpenSSH
	 * guys changed the semantics of src and target.
	 */

	TypesWriter tw = new TypesWriter();
	tw.writeString(target, charsetName);
	tw.writeString(src, charsetName);

	if (debug != null) {
		debug.println("Sending SSH_FXP_SYMLINK...");
		debug.flush();
	}

	sendMessage(Packet.SSH_FXP_SYMLINK, req_id, tw.getBytes());

	expectStatusOKMessage(req_id);
}
 
开发者ID:jianlinwei,项目名称:sshtunnel,代码行数:34,代码来源:SFTPv3Client.java


示例6: fsetstat

import com.trilead.ssh2.sftp.Packet; //导入依赖的package包/类
/**
 * Modify the attributes of a file. Used for operations such as changing the
 * ownership, permissions or access times, as well as for truncating a file.
 * 
 * @param handle
 *            a SFTPv3FileHandle handle
 * @param attr
 *            A SFTPv3FileAttributes object. Specifies the modifications to
 *            be made to the attributes of the file. Empty fields will be
 *            ignored.
 * @throws IOException
 */
public void fsetstat(SFTPv3FileHandle handle, SFTPv3FileAttributes attr)
		throws IOException {
	checkHandleValidAndOpen(handle);

	int req_id = generateNextRequestID();

	TypesWriter tw = new TypesWriter();
	tw.writeString(handle.fileHandle, 0, handle.fileHandle.length);
	tw.writeBytes(createAttrs(attr));

	if (debug != null) {
		debug.println("Sending SSH_FXP_FSETSTAT...");
		debug.flush();
	}

	sendMessage(Packet.SSH_FXP_FSETSTAT, req_id, tw.getBytes());

	expectStatusOKMessage(req_id);
}
 
开发者ID:jianlinwei,项目名称:sshtunnel,代码行数:32,代码来源:SFTPv3Client.java


示例7: sendMessage

import com.trilead.ssh2.sftp.Packet; //导入依赖的package包/类
private final void sendMessage(int type, int requestId, byte[] msg,
		int off, int len) throws IOException {
	int msglen = len + 1;

	if (type != Packet.SSH_FXP_INIT)
		msglen += 4;

	os.write(msglen >> 24);
	os.write(msglen >> 16);
	os.write(msglen >> 8);
	os.write(msglen);
	os.write(type);

	if (type != Packet.SSH_FXP_INIT) {
		os.write(requestId >> 24);
		os.write(requestId >> 16);
		os.write(requestId >> 8);
		os.write(requestId);
	}

	os.write(msg, off, len);
	os.flush();
}
 
开发者ID:jianlinwei,项目名称:sshtunnel,代码行数:24,代码来源:SFTPv3Client.java


示例8: setstat

import com.trilead.ssh2.sftp.Packet; //导入依赖的package包/类
/**
 * Modify the attributes of a file. Used for operations such as changing the
 * ownership, permissions or access times, as well as for truncating a file.
 * 
 * @param path
 *            See the {@link SFTPv3Client comment} for the class for more
 *            details.
 * @param attr
 *            A SFTPv3FileAttributes object. Specifies the modifications to
 *            be made to the attributes of the file. Empty fields will be
 *            ignored.
 * @throws IOException
 */
public void setstat(String path, SFTPv3FileAttributes attr)
		throws IOException {
	int req_id = generateNextRequestID();

	TypesWriter tw = new TypesWriter();
	tw.writeString(path, charsetName);
	tw.writeBytes(createAttrs(attr));

	if (debug != null) {
		debug.println("Sending SSH_FXP_SETSTAT...");
		debug.flush();
	}

	sendMessage(Packet.SSH_FXP_SETSTAT, req_id, tw.getBytes());

	expectStatusOKMessage(req_id);
}
 
开发者ID:jianlinwei,项目名称:sshtunnel,代码行数:31,代码来源:SFTPv3Client.java


示例9: closeHandle

import com.trilead.ssh2.sftp.Packet; //导入依赖的package包/类
private final void closeHandle(byte[] handle) throws IOException
{
	int req_id = generateNextRequestID();

	TypesWriter tw = new TypesWriter();
	tw.writeString(handle, 0, handle.length);

	sendMessage(Packet.SSH_FXP_CLOSE, req_id, tw.getBytes());

	expectStatusOKMessage(req_id);
}
 
开发者ID:dragonlinux,项目名称:connectbot,代码行数:12,代码来源:SFTPv3Client.java


示例10: expectStatusOKMessage

import com.trilead.ssh2.sftp.Packet; //导入依赖的package包/类
private void expectStatusOKMessage(int id) throws IOException
{
	byte[] resp = receiveMessage(34000);

	if (debug != null)
	{
		debug.println("Got REPLY.");
		debug.flush();
	}

	TypesReader tr = new TypesReader(resp);

	int t = tr.readByte();

	int rep_id = tr.readUINT32();
	if (rep_id != id)
		throw new IOException("The server sent an invalid id field.");

	if (t != Packet.SSH_FXP_STATUS)
		throw new IOException("The SFTP server sent an unexpected packet type (" + t + ")");

	int errorCode = tr.readUINT32();

	if (errorCode == ErrorCodes.SSH_FX_OK)
		return;

	throw new SFTPException(tr.readString(), errorCode);
}
 
开发者ID:dragonlinux,项目名称:connectbot,代码行数:29,代码来源:SFTPv3Client.java


示例11: mkdir

import com.trilead.ssh2.sftp.Packet; //导入依赖的package包/类
/**
 * Create a new directory.
 * 
 * @param dirName See the {@link SFTPv3Client comment} for the class for more details.
 * @param posixPermissions the permissions for this directory, e.g., "0700" (remember that
 *                         this is octal noation). The server will likely apply a umask.
 * 
 * @throws IOException
 */
public void mkdir(String dirName, int posixPermissions) throws IOException
{
	int req_id = generateNextRequestID();

	TypesWriter tw = new TypesWriter();
	tw.writeString(dirName, charsetName);
	tw.writeUINT32(AttribFlags.SSH_FILEXFER_ATTR_PERMISSIONS);
	tw.writeUINT32(posixPermissions);

	sendMessage(Packet.SSH_FXP_MKDIR, req_id, tw.getBytes());

	expectStatusOKMessage(req_id);
}
 
开发者ID:dragonlinux,项目名称:connectbot,代码行数:23,代码来源:SFTPv3Client.java


示例12: rm

import com.trilead.ssh2.sftp.Packet; //导入依赖的package包/类
/**
 * Remove a file.
 * 
 * @param fileName See the {@link SFTPv3Client comment} for the class for more details.
 * @throws IOException
 */
public void rm(String fileName) throws IOException
{
	int req_id = generateNextRequestID();

	TypesWriter tw = new TypesWriter();
	tw.writeString(fileName, charsetName);

	sendMessage(Packet.SSH_FXP_REMOVE, req_id, tw.getBytes());

	expectStatusOKMessage(req_id);
}
 
开发者ID:dragonlinux,项目名称:connectbot,代码行数:18,代码来源:SFTPv3Client.java


示例13: rmdir

import com.trilead.ssh2.sftp.Packet; //导入依赖的package包/类
/**
 * Remove an empty directory. 
 * 
 * @param dirName See the {@link SFTPv3Client comment} for the class for more details.
 * @throws IOException
 */
public void rmdir(String dirName) throws IOException
{
	int req_id = generateNextRequestID();

	TypesWriter tw = new TypesWriter();
	tw.writeString(dirName, charsetName);

	sendMessage(Packet.SSH_FXP_RMDIR, req_id, tw.getBytes());

	expectStatusOKMessage(req_id);
}
 
开发者ID:dragonlinux,项目名称:connectbot,代码行数:18,代码来源:SFTPv3Client.java


示例14: mv

import com.trilead.ssh2.sftp.Packet; //导入依赖的package包/类
/**
 * Move a file or directory.
 * 
 * @param oldPath See the {@link SFTPv3Client comment} for the class for more details.
 * @param newPath See the {@link SFTPv3Client comment} for the class for more details.
 * @throws IOException
 */
public void mv(String oldPath, String newPath) throws IOException
{
	int req_id = generateNextRequestID();

	TypesWriter tw = new TypesWriter();
	tw.writeString(oldPath, charsetName);
	tw.writeString(newPath, charsetName);

	sendMessage(Packet.SSH_FXP_RENAME, req_id, tw.getBytes());

	expectStatusOKMessage(req_id);
}
 
开发者ID:dragonlinux,项目名称:connectbot,代码行数:20,代码来源:SFTPv3Client.java


示例15: expectStatusOKMessage

import com.trilead.ssh2.sftp.Packet; //导入依赖的package包/类
private void expectStatusOKMessage(int id) throws IOException {
	byte[] resp = receiveMessage(34000);

	if (debug != null) {
		debug.println("Got REPLY.");
		debug.flush();
	}

	TypesReader tr = new TypesReader(resp);

	int t = tr.readByte();

	int rep_id = tr.readUINT32();
	if (rep_id != id)
		throw new IOException("The server sent an invalid id field.");

	if (t != Packet.SSH_FXP_STATUS)
		throw new IOException(
				"The SFTP server sent an unexpected packet type (" + t
						+ ")");

	int errorCode = tr.readUINT32();

	if (errorCode == ErrorCodes.SSH_FX_OK)
		return;

	throw new SFTPException(tr.readString(), errorCode);
}
 
开发者ID:jianlinwei,项目名称:sshtunnel,代码行数:29,代码来源:SFTPv3Client.java


示例16: mv

import com.trilead.ssh2.sftp.Packet; //导入依赖的package包/类
/**
 * Move a file or directory.
 * 
 * @param oldPath
 *            See the {@link SFTPv3Client comment} for the class for more
 *            details.
 * @param newPath
 *            See the {@link SFTPv3Client comment} for the class for more
 *            details.
 * @throws IOException
 */
public void mv(String oldPath, String newPath) throws IOException {
	int req_id = generateNextRequestID();

	TypesWriter tw = new TypesWriter();
	tw.writeString(oldPath, charsetName);
	tw.writeString(newPath, charsetName);

	sendMessage(Packet.SSH_FXP_RENAME, req_id, tw.getBytes());

	expectStatusOKMessage(req_id);
}
 
开发者ID:jianlinwei,项目名称:sshtunnel,代码行数:23,代码来源:SFTPv3Client.java


示例17: rm

import com.trilead.ssh2.sftp.Packet; //导入依赖的package包/类
/**
 * Remove a file.
 * 
 * @param fileName
 *            See the {@link SFTPv3Client comment} for the class for more
 *            details.
 * @throws IOException
 */
public void rm(String fileName) throws IOException {
	int req_id = generateNextRequestID();

	TypesWriter tw = new TypesWriter();
	tw.writeString(fileName, charsetName);

	sendMessage(Packet.SSH_FXP_REMOVE, req_id, tw.getBytes());

	expectStatusOKMessage(req_id);
}
 
开发者ID:jianlinwei,项目名称:sshtunnel,代码行数:19,代码来源:SFTPv3Client.java


示例18: rmdir

import com.trilead.ssh2.sftp.Packet; //导入依赖的package包/类
/**
 * Remove an empty directory.
 * 
 * @param dirName
 *            See the {@link SFTPv3Client comment} for the class for more
 *            details.
 * @throws IOException
 */
public void rmdir(String dirName) throws IOException {
	int req_id = generateNextRequestID();

	TypesWriter tw = new TypesWriter();
	tw.writeString(dirName, charsetName);

	sendMessage(Packet.SSH_FXP_RMDIR, req_id, tw.getBytes());

	expectStatusOKMessage(req_id);
}
 
开发者ID:jianlinwei,项目名称:sshtunnel,代码行数:19,代码来源:SFTPv3Client.java



注:本文中的com.trilead.ssh2.sftp.Packet类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Logger类代码示例发布时间:2022-05-23
下一篇:
Java ClientPipeAssemblerContext类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap