java.io.File写入写出的一个简单实例
2010-05-08 10:31
573 查看
<!--
/* Font Definitions */
@font-face
{font-family:宋体;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:SimSun;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
{font-family:"/@宋体";
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-parent:"";
margin:0cm;
margin-bottom:.0001pt;
text-align:justify;
text-justify:inter-ideograph;
mso-pagination:none;
font-size:10.5pt;
mso-bidi-font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:宋体;
mso-font-kerning:1.0pt;}
/* Page Definitions */
@page
{mso-page-border-surround-header:no;
mso-page-border-surround-footer:no;}
@page Section1
{size:595.3pt 841.9pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;
mso-header-margin:42.55pt;
mso-footer-margin:49.6pt;
mso-paper-source:0;
layout-grid:15.6pt;}
div.Section1
{page:Section1;}
-->
java.io.File
写入写出的一个简单实例
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class TestIO {
/**
* @param args
*/
public static void main(String[] args)
{
// TODO Auto-generated method stub
byte[] b = new byte[17*1024];
// ** txt
// File f = new File("d://test.txt");
// File outF = new File("d://testOut.txt");
// ** jpg
File f = new File("d://
毫无保留.jpg");
File outF = new File("d://
毫无保留Output.jpg");
try
{
FileInputStream fis = new FileInputStream(f);
FileOutputStream fops = new FileOutputStream(outF);
fis.read(b);
fops.write(b);
// ** for see
// String s = new String(b);
// System.out.println(s);
fis.close();
fops.close();
}
catch(FileNotFoundException fnfe)
{
System.out.println("FileNotFoundException fnfe");
fnfe.printStackTrace();
}
catch(IOException ie)
{
System.out.println("IOException ie");
ie.printStackTrace();
}
}
}
/* Font Definitions */
@font-face
{font-family:宋体;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:SimSun;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
{font-family:"/@宋体";
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-parent:"";
margin:0cm;
margin-bottom:.0001pt;
text-align:justify;
text-justify:inter-ideograph;
mso-pagination:none;
font-size:10.5pt;
mso-bidi-font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:宋体;
mso-font-kerning:1.0pt;}
/* Page Definitions */
@page
{mso-page-border-surround-header:no;
mso-page-border-surround-footer:no;}
@page Section1
{size:595.3pt 841.9pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;
mso-header-margin:42.55pt;
mso-footer-margin:49.6pt;
mso-paper-source:0;
layout-grid:15.6pt;}
div.Section1
{page:Section1;}
-->
java.io.File
写入写出的一个简单实例
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class TestIO {
/**
* @param args
*/
public static void main(String[] args)
{
// TODO Auto-generated method stub
byte[] b = new byte[17*1024];
// ** txt
// File f = new File("d://test.txt");
// File outF = new File("d://testOut.txt");
// ** jpg
File f = new File("d://
毫无保留.jpg");
File outF = new File("d://
毫无保留Output.jpg");
try
{
FileInputStream fis = new FileInputStream(f);
FileOutputStream fops = new FileOutputStream(outF);
fis.read(b);
fops.write(b);
// ** for see
// String s = new String(b);
// System.out.println(s);
fis.close();
fops.close();
}
catch(FileNotFoundException fnfe)
{
System.out.println("FileNotFoundException fnfe");
fnfe.printStackTrace();
}
catch(IOException ie)
{
System.out.println("IOException ie");
ie.printStackTrace();
}
}
}
相关文章推荐
- java io实例一:将2个文件中的内容写入一个新的文件中
- JavaIO简单代码实例
- java异常处理的简单实例和解释,自定义一个异常类
- 一个简单的遗传算法的应用实例(java代码)
- java swing最简单实例(2) 往JFrame里面放一个容器或组件
- java.io File操作,流简单说明
- Java IO-1 File 和 Android 外部存储简单案例
- java 使用线程做的一个简单的ATM存取款实例代码
- (Java2D 学习笔记系列) (一)一个简单的图像填充实例及其分析理解
- java.nio将一个文件的内容写入到另一个的文件简单例子
- 致java初学者:理解每一句java代码,给出一个简单实例。
- Java源码——一个简单的应收账款文件合并程序 (Master file update in accounts receivable system)-Part1
- JAVA 一个简单的文件写入代码(遍历文件夹获取所有文件、写入缓冲池、获取文件绝对路径、按后缀名过滤文件)
- 动态规划的一个简单实例java
- java.io.file使用实例
- Java:一个简单的死锁实例
- java图像界面开发简单实例-ImageIO、JFileChooser、JMenu、JPanel的应用
- (Java2D 学习笔记系列) (一)一个简单的图像填充实例及其分析理解
- 初学者,写了一个java下lucene全文检索简单实例,可直接运行
- java io 写入写出