FileOutputStream写到文件

                File f=new File("e:/abc.txt");
		FileOutputStream fos=null;
		try {
			fos=new FileOutputStream(f);
			if(f.exists())
			{
				System.out.println("文件已存在");
			}
			
			byte b[]=new byte[1024];
			
			String s="阿什顿飞规划局快乐\r\n";
			String s2="阿什顿飞规划局快乐";
		//	b=	s.getBytes();
		
			fos.write(s.getBytes());
			fos.write(s2.getBytes());
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally
		{
			try {
				fos.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

posted @ 2015-10-09 11:01  稻香鱼  阅读(117)  评论(0)    收藏  举报