社区
Java SE
帖子详情
怎样将一个文件的内容读到一个string里?
javafan
2001-05-15 11:40:00
菜鸟问题,请详细回答。
...全文
55
3
打赏
收藏
怎样将一个文件的内容读到一个string里?
菜鸟问题,请详细回答。
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
3 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
yacc_fan
2001-05-15
打赏
举报
回复
class FileApp{
public static void main(String[] args){
byte buffer[] = new byte[2056];
try{
FileInputStream fileIn = new FileInputStream ("fileapp.java");
int bytes = fileIn.read(buffer,0,2056);
String str = new String(buffer,0,bytes);
System.out.println(str);
}
catch( Exception e){
String err = e.toString();
System.out.println(err);
}
}
}
zhou1977
2001-05-15
打赏
举报
回复
String getFromFile = "";
File configFile = new File( path+fileName);
FileReader myFileReader = null;
try
{
myFileReader = new FileReader( configFile );
}
catch( Exception e )
{}
BufferedReader bufReader = new BufferedReader( myFileReader );
try
{
while( (buf = bufReader.readLine()) != null )
{
getFromFile = buf.trim();
}
catch( Exception e )
{}
秦岭刀客
2001-05-15
打赏
举报
回复
你疯了,为什么?
C++ 读
文件
将
文件
内容
读入到字符串
string
中
【代码】C++ 读
文件
将
文件
内容
读入到字符串
string
中。
代码小工具,c++,读
文件
工具,按照行读
文件
,将
文件
中
内容
读到
内存中存放到map<int,
string
>容器中
代码小工具,c++,读
文件
工具,按照行读
文件
,将
文件
中
内容
读到
内存中存放到map<int,
string
>容器中 一、使用场景: 0、从某个
文件
中读取非常多的数据,并需要写入到另
一个
有格式要求的
文件
中,使用这个函数...
Java读取
文件
的
内容
到
String
字符串中
Java读取
文件
的
内容
到
String
字符串中 将
文件
读取到
String
有很多方法可以在Java中将
文件
读取到
String
。在本教程中学习以下几种方法。 使用BufferedReader将
文件
读取到字符串; 使用FileInputStream将
文件
读取到字符...
C++ 读
文件
将
文件
内容
读入到字符串
string
中的方法
#include <
string
> #include <fstream> #include <...//从
文件
读入到
string
里
string
readFileInto
String
(char * filename) { ifstream ifile(filename); //将
文件
读入到o
string
stream对
fstream一次把整个文本
文件
内容
读到
string
里
fstream一次把整个文本
文件
内容
读到
string
里
著名专家Dietmar Kuehl给过两个方法 std::ifstream in("some.file"); std::istreambuf_iterator<char> beg(in), end; std::
string
str...
Java SE
62,614
社区成员
307,326
社区内容
发帖
与我相关
我的任务
Java SE
Java 2 Standard Edition
复制链接
扫一扫
分享
社区描述
Java 2 Standard Edition
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章