home > 比較編 > Perl, PHP, Python, Ruby > files >

ForNext

Only Do What Only You Can Do

188. in memory file

VBScript

JScript

Perl

my ($f, $s);
open($f, ">", \$s);
print $f "lorem ipsum\n";
$s;



PHP

$meg = 1024 * 1024;
$mem = "php://temp/maxmemory:$meg";
$f = fopen($mem, "r+");
fputs($f, "lorem ipsum");
rewind($f);
$s = fread($f, $meg);

Python

from StringIO import StringIO

f = StringIO()
f.write('lorem ipsum\n')
s = f.getvalue()

Python 3 moved StringIO to the io module

Ruby

require 'stringio'

f = StringIO.new
f.puts("lorem ipsum")
f.rewind
s = f.read

PowerShell

Scala

F#

C

C++

C++Builder

VC++

C#

Java

Objective-C

D

VB

VB.NET

Delphi

Ada

PL/SQL

T-SQL

関数型

inserted by FC2 system