java数据流实验代码 java数据流编程实验

java把数据库读取的数据通过流写入到csv文件里,请问怎么写代码?请求。

File file = new File("d:/test.csv");

10年积累的成都网站设计、网站制作、外贸营销网站建设经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先网站设计后付款的网站建设流程,更有淅川免费网站建设让你可以放心的选择与我们合作。

BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file)));

bw.write("123456");

bw.write("89898");

bw.close();

JAVA数据流

import java.io.*;

public class Example9_3{

public static void main(String args[ ]){

File file=new File("hello.txt");

byte b[]="欢迎welcome".getBytes();//将字符串“欢迎welcome”存入数组b

try{ FileOutputStream out=new FileOutputStream(file);//打开hello。txt的输出流

out.write(b);//将b写入hello.txt文件中

out.close();//关闭输出流

FileInputStream in=new FileInputStream(file);//打开hello.txt的输入流

int n=0;

while((n=in.read(b,0,2))!=-1){//从hello.txt中每两个字节读取数据

String str=new String(b,0,n);//将数据存入str

System.out.println(str);//输出str,即输出欢迎welcome

}

}

catch(IOException e){//捕获io异常

System.out.println(e);

}

}

}

java题 任选一个文件,使用文件输入流,将其数据读取出来,并打印到控制台!! 代码简单能够有注释

FileInputStream file=new FileInputStream(//这里写文件路径和名字);

BufferedReader reader=new BufferedReader(new InputStreamReader(file));//这里得到流

while((String b=reader.readerLine())!=null){//这里都文件一行一行的都

system.out.priteln(b);//输出到控制台

}

求采纳 纯手打


当前题目:java数据流实验代码 java数据流编程实验
当前URL:http://scyanting.com/article/dddspjd.html