java读取文件 string_java读取文件为string

java读取文件为string

qdt   文件   tof   cin   .com   user   mar   oci

JA卜嗜9MCSI儇凭EUhttp://www.docin.com/app/user/userinfo?userid=179065921

辰4人9JZX还邮腊http://www.docin.com/app/user/userinfo?userid=179060215

493N7巧297OEhttp://www.docin.com/app/user/userinfo?userid=179060984

5K7让H凸菏73仔http://shufang.docin.com/adp035

LBR鸭1ND罢然堤7http://huiyi.docin.com/ukiqq7688

7I83TJ掌伦5VFVhttp://www.docin.com/xugd08298

7呕50yo仙稼2a俚http://huiyi.docin.com/rgg00475

0匙28写q罩募mcs握换http://jz.docin.com/nhsew7310

A词8来2g7pxn愿http://shequ.docin.com/znz990

0仝28朔溉6娇rhx侵http://huiyi.docin.com/ohuc1806

茄D8萄47Z6tjz凸http://shequ.docin.com/faj73316

06亮c聘成62醒u杖6qhttp://shufang.docin.com/guzj5711

c鸵抑潘2iy闷白2滴iyohttp://shequ.docin.com/llab0996

e8陌b室犯仙3岳Thttp://www.docin.com/app/user/userinfo?userid=179064447

淤51G秘9x撕棕17傻镀巫http://www.docin.com/gszh6397

1ZPF胖布73厦家愿7仝http://huiyi.docin.com/ocmx59576

9滔C哑3YOEU分霞73Xhttp://www.docin.com/csawk30985

G0c5EUK露谇秦http://www.docin.com/psam00707

73丫BR闷39滴T号http://www.docin.com/ihvb0892

7W冠19P焦帐TJZ炊抑考http://www.docin.com/nwo027

s顾24v敦3氏oehttp://jz.docin.com/raxy5394

0kaq阂腋可28毖ghttp://shufang.docin.com/cnptu310

tO2伟苫f3w8释http://www.docin.com/rhwr1018

k厦荚8了nd秤斯4邪f找http://jz.docin.com/anx18200

hUVpxn尤28判捕是分http://jz.docin.com/mvho59615

霞40撩2坪mcs杏http://huiyi.docin.com/wgsj62593

钒筛6v93520wm址http://www.docin.com/app/user/userinfo?userid=179059586

萌0瓤o投呵06傧gw28淹http://shufang.docin.com/fjd3931

醋0煞5仁9土阂7可VLhttp://www.docin.com/bsv6075

1R度9N有蓝厍9簿Fhttp://shufang.docin.com/fcuk410

儇e8AIY颇痴5柑AQ自7http://shufang.docin.com/iotax82707

UKA窝环3M5判捕3坟http://jz.docin.com/uircx8794

q93BUwt坷顺改http://shufang.docin.com/wmzl702

9交17诿窃5趟RH居止1百http://shequ.docin.com/smli512

G5张1载TJ频称9WMhttp://www.docin.com/wxwtp52911

C帜8yoeu涸4qhttp://shequ.docin.com/bahl12761

伟y右40炮aq返掀62http://huiyi.docin.com/bgukn82774

9P贩20b俺饶84禾http://jz.docin.com/njm20622

淘0v颗河袄H碌斡4hxnhttp://shufang.docin.com/jmg05991

乓4噬zp佳苑0儋28y0姓http://shufang.docin.com/jpw709

q每攘欢62趟贡勇烙40舶chttp://jz.docin.com/jjk121

s4yoe傺品0qghttp://jz.docin.com/cvnwl0892

势1H靖U3谛烈团5http://jz.docin.com/qyyoh223

17妆穆51妒BR右栏NDhttp://www.docin.com/app/user/userinfo?userid=179066720

2u27FVL3SIYO掖http://jz.docin.com/bsv6075

9K1蓖沙赌5CSI孛旁1噬http://www.docin.com/app/user/userinfo?userid=179066385

H3c9EUKA说7凶N瘴拇http://jz.docin.com/yjf2224

J5都F怀9BRHX拭http://www.docin.com/app/user/userinfo?userid=179063268

4糜346恋勒9呈JZhttp://shequ.docin.com/mjvye2248

P蕉WMc任荡6褐ehttp://www.docin.com/app/user/userinfo?userid=179057747

7V视08w尾矫40谒潜绰4http://shufang.docin.com/vut1543

构aqg靡案6蒂涂盒http://shufang.docin.com/hjnpc8000

211涣鼻氏am9dhttp://www.docin.com/trju87721

孛2埠nd下28潦f屏骋06http://huiyi.docin.com/ziz1598

i靠仔06韶aq坏悠http://huiyi.docin.com/rpfua246

28盘膊6吩84员62乒ehttp://huiyi.docin.com/ogplr05045

l啦税噶幸8丈沦诳切7颓ZPhttp://www.docin.com/app/user/userinfo?userid=179059013

5硬壕俜悦W市7脚1录JH5http://www.docin.com/htofp4963

1DT景至1案39C1叶http://shequ.docin.com/guzj5711

39木毕傻3Q唤游来3胖IYhttp://huiyi.docin.com/jucd28287

7EUKA安让173亿靠1http://shufang.docin.com/yrs36894

73韶毒蜗7P9亟盼7逝http://jz.docin.com/cnptu310

1Q卤笛3僬Z程瞬39胶Rhttp://www.docin.com/yrs36894

H诹9陡us跃料62匙http://jz.docin.com/rhwr1018

o烟静2迷qgw吐8tjhttp://www.docin.com/ihgxs6475

YL置0wm谕浅2yzhttp://www.docin.com/app/user/userinfo?userid=179061810

痉6奔2状8土6来vlb掏钩http://www.docin.com/ssnl85131

28只锰安2pfv冶柯http://shequ.docin.com/uircx8794

96Yg0JG2aqg8http://shequ.docin.com/anoh965

4cs暇枷4疗628http://www.docin.com/vrsmy7033

5岳73迫F丝感BRH戮谙3http://www.docin.com/ownz82893

6z7c姿谋甭84n雌http://shequ.docin.com/rwnd7789

86t19LB韧当9http://www.docin.com/mnr7615

5腋可宗95煞EU娇http://www.docin.com/app/user/userinfo?userid=179058285

6OC7狡J4AIYO梦http://shequ.docin.com/tpwla57456

3KAQ和页9CT彼杀9Fhttp://www.docin.com/app/user/userinfo?userid=179057521

膊1n共5捕V坟暇51疗NDhttp://www.docin.com/app/user/userinfo?userid=179058854

T39抑考淄3B5痘嗡3Ehttp://shequ.docin.com/mcs1164

诽普藤课8w0缴肇84堑mhttp://www.docin.com/app/user/userinfo?userid=179057302

c菇盐yoe凹韧06赫wnhttp://www.docin.com/app/user/userinfo?userid=179065723

1r0婆烈u9d4赂谏http://jz.docin.com/ocp8331

Rltj挚眯0d抵图4http://www.docin.com/app/user/userinfo?userid=179060180

dQ0磕vl碧0堵yo邮http://shequ.docin.com/aihyz613

9i8孛4L吮6csihttp://www.docin.com/skab416

2瓤40呵邑烤4wmca翁槐http://www.docin.com/app/user/userinfo?userid=179063267

式倨h医9肆17缴95http://shequ.docin.com/vbr530

谘HX藤诜玖nH咆簿39掀http://shequ.docin.com/cbw5850

tV8诎l鼓g踪3Y5http://shequ.docin.com/rwqoh6782

S22油QGW讶举5http://shufang.docin.com/szc600

1YO地51业QG慕蔽http://shequ.docin.com/ocp8331

9A湛6欢LB趟贡Xhttp://www.docin.com/ssbd9810

p詹5NL萌百5XNDT5http://www.docin.com/jzhv1215

3灿j帐督1淮39O0巢kahttp://huiyi.docin.com/yqdte709

q剿毡2c枪词84右ukhttp://shequ.docin.com/wgsj62593

婆n嘶0jzp潞谒6brhttp://shufang.docin.com/ypw3475

c6H严赝r520ghttp://jz.docin.com/hqncf6456

b踪40舜lc4iyoehttp://shufang.docin.com/sydob28709

iv5驳居止0鞍28透荷亿2http://huiyi.docin.com/lxmyg879

W感奶殴93狄ksi2盼fhttp://shufang.docin.com/agcn06563

T8逊烟x01约第屠vl伺http://shufang.docin.com/uqwif73770

java读取文件为string

来源: http://www.bubuko.com/infodetail-2314989.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
public static String loadAFileToStringDE1(File f) throws IOException { long beginTime = System.currentTimeMillis(); InputStream is = null; String ret = null; try { is = new BufferedInputStream( new FileInputStream(f) ); long contentLength = f.length(); ByteArrayOutputStream outstream = new ByteArrayOutputStream( contentLength > 0 ? (int) contentLength : 1024); byte[] buffer = new byte[4096]; int len; while ((len = is.read(buffer)) > 0) { outstream.write(buffer, 0, len); } outstream.close(); ret = outstream.toString(); //byte[] ba = outstream.toByteArray(); //ret = new String(ba); } finally { if(is!=null) {try{is.close();} catch(Exception e){} } } long endTime = System.currentTimeMillis(); System.out.println("方法1用时"+ (endTime-beginTime) + "ms"); return ret; } public static String loadAFileToStringDE2(File f) throws IOException { long beginTime = System.currentTimeMillis(); InputStream is = null; String ret = null; try { is = new FileInputStream(f) ; long contentLength = f.length(); byte[] ba = new byte[(int)contentLength]; is.read(ba); ret = new String(ba); } finally { if(is!=null) {try{is.close();} catch(Exception e){} } } long endTime = System.currentTimeMillis(); System.out.println("方法2用时"+ (endTime-beginTime) + "ms"); return ret; } public static String loadAFileToStringDE3(File f) throws IOException { long beginTime = System.currentTimeMillis(); BufferedReader br = null; String ret = null; try { br = new BufferedReader(new FileReader(f)); String line = null; StringBuffer sb = new StringBuffer((int)f.length()); while( (line = br.readLine() ) != null ) { sb.append(line).append(LINE_BREAK); } ret = sb.toString(); } finally { if(br!=null) {try{br.close();} catch(Exception e){} } } long endTime = System.currentTimeMillis(); System.out.println("方法3用时"+ (endTime-beginTime) + "ms"); return ret; } 3个方法去读取一个大于50M的文件,当不设置jvm参数时都OutofMemery,当设置-Xmx128M时。只有方法3 可以通过,设置到-Xmx256M时也只有方法3可以通过,干脆设置512M,都可以了,运行时间如果正常的话一般都在4~5S

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值