想把一个字符串输出到一个文件,FileOutputStream filewriter=new FileOutputStream("file.txt");但是这种方式是以字节数组的方式输出,不知道有没有字符串方式直接输出的方式?怎么输出?
我找了一个BufferedStreamWriter类,但是我不知道和上面的怎么转换,郁闷。高手救救我吧。
我找了一个BufferedStreamWriter类,但是我不知道和上面的怎么转换,郁闷。高手救救我吧。
解决方案 »
- 我现在想做个树,数据是从oracle中读出来的,这个树每个结点前要代个复选框,
- 菜鸟问题之浏览图片缩略图的生成
- 怎样求当前日期前一年的时间
- 关于Inflater解压的问题
- JAVA中那几个颜色都用什么INT代表呢?
- 关于System.gc()探讨
- axis2的wsdl2java的问题
- 怎么用UltraEdit呀?
- J2SE、J2EE、J2ME
- cs(se)项目,jdk版本过低,需要升级问题
- 我用jbuilder 2005运行jsp时,出现unable to find java class on classpath:jsp:usebean错误,是什么意思?谢了
- 一个有关包和CLASSPATH的问题
public int copy(InputStream input,OutputStream output) throws IOException {
byte[] b = new byte[DEFAULT_BUFFER_SIZE];
int value = 0,n = 0;
while((n = input.read(b)) != -1) {
output.write(b,0,n);
value += n;
}
return value;
}
public int copy(OutputStream output,InputStream input) throws IOException {
byte[] b = new byte[DEFAULT_BUFFER_SIZE];
int value = 0,n=0;
while((n = input.read(b)) != -1) {
output.write(b,0,n);
value += n;
}
return value;
} public void copy(byte[] b,OutputStream output) throws IOException {
output.write(b);
} public void copy(byte[] b,Writer writer) throws IOException {
ByteArrayInputStream in = new ByteArrayInputStream(b);
copy(in, writer);
} public void copy(InputStream input,Writer writer) throws IOException {
InputStreamReader in = new InputStreamReader(input);
copy(in,writer);
} public void copy(Reader reader,OutputStream output) throws IOException {
OutputStreamWriter writer = new OutputStreamWriter(output);
copy(reader,writer);
} public void copy(String input,OutputStream output) throws IOException {
StringReader in = new StringReader(input);
OutputStreamWriter out = new OutputStreamWriter(output);
copy(in,out);
out.flush();
} public void copy(String input,Writer writer) throws IOException {
writer.write(input);
} public int copy(Reader reader,Writer writer) throws IOException {
char[] buffer = new char[DEFAULT_BUFFER_SIZE];
int count = 0;
int n = 0;
while ((n = reader.read(buffer)) != -1) {
writer.write(buffer, 0, n);
count += n;
}
return count;
}