您的位置:首页 > 编程语言 > Java开发

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();

}

}

}

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  import file string byte ie class