首页 > 编程语言 > 详细

Java学习之IO一

时间:2016-01-23 23:11:02      阅读:256      评论:0      收藏:0      [点我收藏+]

File的操作

 1 package com.gh.file;
 2 import java.io.File;
 3 import java.io.IOException;
 4 /**
 5  * File操作
 6  * @author ganhang
 7  *
 8  */
 9 public class FileDemo {
10     public static void main(String[] args) {
11         //File.separator表示 ‘/‘
12         File file =new File("1.txt");
13         try {
14             file.createNewFile();
15         } catch (IOException e) {
16             e.printStackTrace();
17         }
18         System.out.println(file.getParent());
19         File file2 =new File("D:\\");
20         String [] filenames=file2.list();
21         for(String s:filenames){//输出d盘下的所有文件名
22             System.out.println(s);
23         }
24     }
25 }

 

Java学习之IO一

原文:http://www.cnblogs.com/ganhang-acm/p/5154240.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!