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;
}
分享到:
相关推荐
文件转换(inputString)请勿乱下载
android用base64实现文件与string相互转换,绝对好用已测试通过。
文件字符串查找工具(File String Finder)1.4汉化版
BitVector CookieUtil DES FileUtil HttpUtil ImageFile JavaScriptString JsonHelper StringUtil Thumbnail Utils WebFileInfo
File String Finder能够从指定范围内查找全部或部分文件名,查找文件中的一个字符或短语,支持区分大小写,支持以文本/十六进制类型,当FileStringFinder在文件中搜索字符串时,它只读取部分文件.这些部分与你...
String path = IndexPath.Index_File_Path; try { String temp = readTxt(path); System.out.println(temp); } catch (IOException e1) { // TODO Auto-generated catch block e1....
public static String loadAFileToStringDE1(File f) throws IOException { long beginTime = System.currentTimeMillis(); InputStream is = null; String ret = null; try { is = new BufferedInputStream( ...
File file = new File(path) 2、讲一个Uri转换成一个path 以选择一张图片为例: String path = FileTools.getRealPathFromUri(content,uri); //自定义方法在下面 public static String getRealPathFromUri...
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor...
在PowerBuilder中操作BLOB数据的技巧
C#中,Image为源自 Bitmap 和 Metafile 的类提供功能的抽象基类,也就是说更通用,当我们用Image.FromFile(“xxx”)时创建出来的是Image的某个派生类实体,所以我用Image作为参数,而不是Bitmap之类的。 ...
wold转pdfwold转pdfwold转pdfwold转pdfwold转pdfwold转pdfwold转pdfwold转pdfwold转pdfwold转pdf
--WisFileRead.transformWisToCsv(String inputFile,String outPutPath) --单wis文件转csv --WisFileRead.transformWisToTxt(String inputFile,String outPutPath) --单wis文件转txt --WisFileRead....
(FileInfo*) void AppendAllText(string path, string contents), 将文本contents附加到文件path中(如果文件不存在,则创建) bool Exists(string path)判断文件path是否存在 string[] ReadAllLines(string path)...
主要介绍了java 中InputStream,String,File之间的相互转化对比的相关资料,需要的朋友可以参考下
这个findFile函数功能强大,完整。 Imports System.Collections.Generic Imports System.IO Friend Class FindFiles Public Shared GRAPHIC_FILES As String() = New String() {"*.bmp", "*.jpg", "*.jpeg...
文件字符串工具npm软件包用法首先,安装file-string-tools ,在终端中输入: $ npm install file-string-tools例子 const FileTOOLS = require ( 'file-string-tools' ) ;const tool = new FileTOOLS ( ) ;console ....
1.File(String pathname):根据一个路径得到File对象 2.File(String parent,String child):根据一个目录和一个子文件/目录得到File对象 3.File(File parent,String child):根据一个父File对象和一个子文件/目录得到...
/*** *string.h - declarations for string manipulation functions ...* This file contains the function declarations for the string * manipulation functions. * [ANSI/System V] * * [Public] * ****/
FileDescription:string;{说明} FileVersion:string;{文件版本} InternalName:string;{内部名称} LegalCopyright:string;{版权} LegalTrademarks:string;{合法商标} OriginalFilename:string;{源文件名} ...