// TODO Auto-generated method stub
//File file = new File("D:\\Android\\workspace\\Practice1\\src\\test4", "new1.txt");
//String str = file.getName();
//file.delete();

// try{
// Runtime rt = Runtime.getRuntime();
//
// File file = new File("D:\\Program Files (x86)\\CodeBlocks", "codeblocks.exe");
// System.out.println("打开codeblocks");
// rt.exec(file.getAbsolutePath());
// file = new File("D:\\酷狗\\KGMusic", "KuGou.exe");
// System.out.println("打开酷狗");
// rt.exec(file.getAbsolutePath());
// file = new File("D:\\净网大师\\ADSafe", "ADSafeSvc.exe");
// System.out.println("打开净网大师");
// rt.exec(file.getAbsolutePath());
// }catch(Exception e){
// System.out.println(e);
// }

// try{
// File f = new File("D:\\Android\\workspace\\Practice1\\src\\test4", "file.txt");
// FileInputStream in = new FileInputStream(f);
// int n = -1;
// byte [] a= new byte[100];
//
// while((n = in.read(a, 0, 100)) != -1){
// String s = new String(a, 0, n);
// System.out.print(s);
// }
// in.close();
// }
// catch(Exception e){
// System.out.println(e);
// }

// try{
// byte []b = "我是你爸爸".getBytes();
// File file = new File("D:\\Android\\workspace\\Practice1\\src\\test4", "empty.txt");
// FileOutputStream out = new FileOutputStream(file);
// out.write(b);
// out.close();
// out = new FileOutputStream(file, true);
// b = ",当文件字符输出流的构造方法中有true参数时,可以在文件末尾追加文字".getBytes();
// out.write(b);
//
// out.close();
//
// }
// catch(Exception e){
// System.out.println(e);
// }

// byte []b = "我是你大爷".getBytes();
// System.out.println(b);

// File sourceFile = new File("D:\\Android\\workspace\\Practice1\\src\\test4","a.txt");
// File targetFile = new File("D:\\Android\\workspace\\Practice1\\src\\test4","b.txt");
//
// char c[] = new char[19];
// try{
// Reader in = new FileReader(sourceFile);
// Writer out = new FileWriter(targetFile, true);
// int n = -1;
// while((n = in.read(c))!= -1){
// out.write(c, 0, n);
// }
// out.flush();//使缓冲区的内容马上写入目的地
// out.close();
// }catch(Exception e){
// System.out.println(e);
//
// }

// try{
//
// FileReader inOne = new FileReader("D:\\Android\\workspace\\Practice1\\src\\test4\\a.txt");
// BufferedReader bufferedRead = new BufferedReader(inOne);
//
// FileWriter tofile = new FileWriter("D:\\Android\\workspace\\Practice1\\src\\test4\\to.txt");
// BufferedWriter bufferedWrite = new BufferedWriter(tofile);
//
// String str = null;
//
// while((str = bufferedRead.readLine()) != null){
// StringTokenizer fenxi = new StringTokenizer(str);
// str = str + "单词个数:" + fenxi.countTokens();
// bufferedWrite.write(str);
// bufferedWrite.newLine();
// }
//
// bufferedWrite.close();
// tofile.close();
// bufferedRead.close();
// inOne.close();
//
//
// }
// catch(Exception e){
// System.out.println(e);
// }

//
// RandomAccessFile inAndOut = null;
// int data[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 111};
// try{
// inAndOut = new RandomAccessFile("D:\\Android\\workspace\\Practice1\\src\\test4\\random.txt", "rw");
// for(int i = 0; i < data.length; i++){
// inAndOut.writeInt(data[i]);
// }
//
// for(long i = data.length - 1; i >= 0; i--){
// inAndOut.seek(i * 4);
// System.out.printf("\t%d", inAndOut.readInt());
// }
// inAndOut.close();
// }catch(Exception e){
// System.out.println(e);
// }
//

System.out.println(Math.round(-13.4));
char 坏 = '坏';

ok:while(true){
while(true){
System.out.println("我只循环一次");
break ok;
}
}

int num = (int)Math.random() * 100;

//break String s = null;
//char 好 = 坏;

}

java文件读写常用方法的更多相关文章

  1. java 文件读写的有用工具

    java 文件读写的有用工具 package org.rui.io.util; import java.io.BufferedReader; import java.io.File; import j ...

  2. java文件读写的两种方式

    今天搞了下java文件的读写,自己也总结了一下,但是不全,只有两种方式,先直接看代码: public static void main(String[] args) throws IOExceptio ...

  3. java文件读写操作

    Java IO系统里读写文件使用Reader和Writer两个抽象类,Reader中read()和close()方法都是抽象方法.Writer中 write(),flush()和close()方法为抽 ...

  4. java文件读写操作类

    借鉴了项目以前的文件写入功能,实现了对文件读写操作的封装 仅仅需要在读写方法传入路径即可(可以是绝对或相对路径) 以后使用时,可以在此基础上改进,比如: 写操作: 1,对java GUI中文本框中的内 ...

  5. Java 文件读写操作

    1[1]按字节读写,一次只读取一个字节,效率比较低 package bk1; import java.io.File; import java.io.FileInputStream; import j ...

  6. Java文件读写分析

    本文内容:IO流操作文件的细节分析:分析各种操作文件的方式. 读写一个文件 从一个示例开始分析,如何操作文件: /** * 向一个文件中写入数据 * @throws IOException */ pr ...

  7. java文件读写操作指定编码格式

    读文件: BufferedReader 从字符输入流中读取文本,缓冲各个字符,从而提供字符.数组和行的高效读取. 可以指定缓冲区的大小,或者可使用默认的大小.大多数情况下,默认值就足够大了. 通常,R ...

  8. java文件读写工具类

    依赖jar:commons-io.jar 1.写文件 // by FileUtilsList<String> lines = FileUtils.readLines(file, " ...

  9. java 文件读写--转载

    读文件 http://www.baeldung.com/java-read-file Java – Read from File 1. Overview In this tutorial we’ll ...

随机推荐

  1. 阻止element组件中的<el-input/>的粘贴功能

    需求: 阻止element组件中的<el-input/>的粘贴功能 实现思路: <el-input/>组件是由外层<div>和内层的<input>组成的 ...

  2. MySQL中哈希表

    也称为散列表 由直接寻址表改进而来.先看直接寻址表 当关键字的全域U比较小时,直接寻址是一种简单而有效的技术.加入某应用要用到一个动态集合,其中每个元素都有一个取自全域U={0,1,...,m-1}的 ...

  3. KVM WEB管理工具webvirtmgr安装和使用

    生产环境的KVM宿主机越来越多,需要对宿主机的状态进行调控.这里用webvirtmgr进行管理.图形化的WEB,让人能更方便的查看kvm 宿主机的情况和操作 1 安装支持的软件源 yum -y ins ...

  4. STL学习笔记— —容器map和multimap

    简单介绍 在头文件<map> 中定义 namespace std { template <typename Key, typename T, typename Compare = l ...

  5. POJ 1470 Closest Common Ancestors【近期公共祖先LCA】

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/u013912596/article/details/35311489 题目链接:http://poj ...

  6. Kafka高可用的保证

    zookeeper作为去中心化的集群模式,消费者需要知道现在那些生产者(对于消费者而言,kafka就是生产者)是可用的.    如果没有zookeeper每次消费者在消费之前都去尝试连接生产者测试下是 ...

  7. mysql-5.7.16-linux-glibc2.5-x86_64精简后的主从配置

    1.创建复制账号,并授予复制权限CREATE USER 'fansik'@'10.%' IDENTIFIED BY 'fansik';GRANT REPLICATION SLAVE ON *.* TO ...

  8. LVM逻辑卷管理器

    LVM概述 通过使用Linux的逻辑卷管理器(Logical Volume Manager, LVM),用户可以在系统运行时动态调整文件系统的大小,把数据从一块硬盘重定位到另一块硬盘,也可以提高I/O ...

  9. Eclipse 输出的文本乱码

    Version: Mars.2 Release (4.5.2)Build id: 20160218-0600 在使用时,发现文本编辑器中的文字出现了乱码.然后在项目的Properties->&g ...

  10. Activity的生命周期整理

    Activity主要的三种状态: Running(运行):在屏幕前台(位于当前任务堆栈的顶部) Paused(暂停):失去焦点但仍然对用户可见(覆盖Activity可能是透明或未完全遮挡) Stopp ...