Strem String Memory TStringStream
System.SysUtils
一、TStringStream方法
Strem>String
TMemoryStream to String
stm: TStream;
ss: TStringStream;
#include "System.SysUtils.hpp"
DataString
image.picture.savetoStream(stm);
ss := TStringStream.Create('', TEncoding.Unicode);
ss.CopyFrom(stm, 0);
str := ss.DataString;
stm.Free;
ss.Free;
String>Strem
stm: TStream;
ss: TStringStream;
stm := TMemoryStream.Create;
ss := TStringStream.Create('', TEncoding.Unicode);
ss.WriteString(str);
ss.Position := 0;
stm.CopyFrom(ss, ss.Size);
stm.Position := 0;
二、TBytes和stringof转换
Strem>String
abyte: TBytes;
SetLength(abyte, stm.Size);
stm.Read(abyte, stm.Size);
str := stringof(abyte);
String>Strem
abyte := BytesOf(gstr);
stm.Write(abyte, Length(abyte));
stm.Position := 0;
img.picture.LoadFromStream(stm);
function BytesOf(const Val: UnicodeString): TBytes;
begin
Result := TEncoding.Default.GetBytes(Val);
end;
function StringOf(const Bytes: TBytes): UnicodeString;
begin
if Assigned(Bytes) then
Result := TEncoding.Default.GetString(Bytes, Low(Bytes), High(Bytes) + 1)
else
Result := '';
end;
Strem String Memory TStringStream的更多相关文章
- 代码演示C#中string和StingBuilder内存中的区别
关于 string和StringBuilder的区别参考MSDN.本文用程序演示它们在内存中的区别,及其因此其行为不同. //Demo string memory model namespace C ...
- 【原创】大数据基础之Spark(2)Spark on Yarn:container memory allocation容器内存分配
spark 2.1.1 最近spark任务(spark on yarn)有一个报错 Diagnostics: Container [pid=5901,containerID=container_154 ...
- solidity数据位置-memory,storage和calldata
有三种类型,memory,storage和calldata,一般只有外部函数的参数(不包括返回参数)被强制指定为calldata.这种数据位置是只读的,不会持久化到区块链 storage存储或memo ...
- solidity中的memory和 storage详解
Solidity是一种智能合约高级语言,运行在Ethereum虚拟机(EVM)之上.这里我会讲解一下关键字storage和memory的区别. storage的结构是在合约部署创建时,根据你的合约中状 ...
- C++ TUTORIAL - MEMORY ALLOCATION - 2016
http://www.bogotobogo.com/cplusplus/memoryallocation.php Variables and Memory Variables represent st ...
- 理解Docker(4):Docker 容器使用 cgroups 限制资源使用
本系列文章将介绍Docker的有关知识: (1)Docker 安装及基本用法 (2)Docker 镜像 (3)Docker 容器的隔离性 - 使用 Linux namespace 隔离容器的运行环境 ...
- sysbench 压力测试
200 ? "200px" : this.width)!important;} --> 介绍 sysbench是一个模块化.跨平台.多线程基准测试工具,主要用于测试不同系统参 ...
- 理解Docker(1):Docker 安装和基础用法
本系列文章将介绍Docker的有关知识: (1)Docker 安装及基本用法 (2)Docker 镜像 (3)Docker 容器的隔离性 - 使用 Linux namespace 隔离容器的运行环境 ...
- sysbench的安装与使用(with MySQL)
sysbench是一款开源的多线程性能测试工具,可以执行CPU/内存/线程/IO/数据库等方面的性能测试. 项目主页: http://sysbench.sourceforge.net/ 安装文档htt ...
随机推荐
- 安装hadoop 2.2.0
安装环境为 CentOS 64位系统, 大概分下面几个步奏, 0. 安装JDK1. 配置SSH2. 配置/etc/hosts3. 拷贝hadoop包到没台机器上4. 修改hadoop配置文件5. 关闭 ...
- ballerina 学习七 object 创建&& 初始化
在 ballerina 总中object 是一个包含public private 类型字段同时包含函数,需要开发人员进行自定义类型以及行为 说白了,就是类似面向对象的class 基本使用 代码 imp ...
- drone 学习二 pipeline 说明
1. 基本语法 pipeline: backend: image: golang commands: - go build - go test frontend: image: node comman ...
- javascript系列学习----Creating objects
在javascript语言里面,一切皆是对象,对象是它的灵魂,值得我们学习和领悟对象的概念和使用,下面我会引用实例来进行说明. 1)创建对象 方法一:js的对象方法构造 var cody = new ...
- mysql大数据量之limit优化
背景:当数据库里面的数据达到几百万条上千万条的时候,如果要分页的时候(不过一般分页不会有这么多),如果业务要求这么做那我们需要如何解决呢?我用的本地一个自己生产的一张表有五百多万的表,来进行测试,表名 ...
- HDOJ4763(KMP原理理解)
Theme Section Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tot ...
- appium+python自动化34-获取元素属性get_attribute
获取text # coding:utf-8 from appium import webdriver from time import sleep desired_caps = { 'platform ...
- java代码----I/O流从控制台输入信息判断并抛出异常
package com.a.b; import java.io.*; public class Yu { public static void main(String[] args) throws I ...
- Redis: Redis支持五种数据类型
ylbtech-Redis: Redis支持五种数据类型 Redis支持五种数据类型:string(字符串) ,hash(哈希),list(列表),set(集合)及zset(sorted set:有序 ...
- Mac brew安装MongoDB
brew简介安装 brew 又叫Homebrew,是Mac OSX上的软件包管理工具,能在Mac中方便的安装软件或者卸载软件, 只需要一个命令, 非常方便 brew类似ubuntu系统下的apt-ge ...