java文件读写常用方法
// 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文件读写常用方法的更多相关文章
- java 文件读写的有用工具
java 文件读写的有用工具 package org.rui.io.util; import java.io.BufferedReader; import java.io.File; import j ...
- java文件读写的两种方式
今天搞了下java文件的读写,自己也总结了一下,但是不全,只有两种方式,先直接看代码: public static void main(String[] args) throws IOExceptio ...
- java文件读写操作
Java IO系统里读写文件使用Reader和Writer两个抽象类,Reader中read()和close()方法都是抽象方法.Writer中 write(),flush()和close()方法为抽 ...
- java文件读写操作类
借鉴了项目以前的文件写入功能,实现了对文件读写操作的封装 仅仅需要在读写方法传入路径即可(可以是绝对或相对路径) 以后使用时,可以在此基础上改进,比如: 写操作: 1,对java GUI中文本框中的内 ...
- Java 文件读写操作
1[1]按字节读写,一次只读取一个字节,效率比较低 package bk1; import java.io.File; import java.io.FileInputStream; import j ...
- Java文件读写分析
本文内容:IO流操作文件的细节分析:分析各种操作文件的方式. 读写一个文件 从一个示例开始分析,如何操作文件: /** * 向一个文件中写入数据 * @throws IOException */ pr ...
- java文件读写操作指定编码格式
读文件: BufferedReader 从字符输入流中读取文本,缓冲各个字符,从而提供字符.数组和行的高效读取. 可以指定缓冲区的大小,或者可使用默认的大小.大多数情况下,默认值就足够大了. 通常,R ...
- java文件读写工具类
依赖jar:commons-io.jar 1.写文件 // by FileUtilsList<String> lines = FileUtils.readLines(file, " ...
- java 文件读写--转载
读文件 http://www.baeldung.com/java-read-file Java – Read from File 1. Overview In this tutorial we’ll ...
随机推荐
- influxDB 变换类函数
1.DERIVATIVE()函数 作用:返回一个字段在一个series中的变化率. InfluxDB会计算按照时间进行排序的字段值之间的差异,并将这些结果转化为单位变化率.其中,单位可以指定,默认为1 ...
- amortized analysis
w https://en.wikipedia.org/wiki/Amortized_analysis In computer science, amortized analysis is a meth ...
- Python3.6全栈开发实例[026]
27.文件a.txt内容:每一行内容分别为商品名字,价钱,个数.apple 10 3tesla 100000 1mac 3000 2lenovo 30000 3chicken 10 3通过代码,将其构 ...
- 老铁,这年头不会点git真不行
作者:武沛齐 出处:http://www.cnblogs.com/wupeiqi/ 版本控制 说到版本控制,脑海里总会浮现大学毕业是写毕业论文的场景,你电脑上的毕业论文一定出现过这番景象! 毕业论文_ ...
- MYSQL中case when then else end 用法
条件语句 delimiter \\CREATE PROCEDURE proc_if ()BEGIN declare i int default 0; if i = 1 THEN ...
- Java并发—线程池框架Executor总结(转载)
为什么引入Executor线程池框架 new Thread()的缺点 每次new Thread()耗费性能 调用new Thread()创建的线程缺乏管理,被称为野线程,而且可以无限制创建,之间相互竞 ...
- Scrapy框架2
一.进程.线程.协成 1.进程.线程.协成之间的关系 1. 线程是计算机中最小的工作单元. 2. 进程是提供资源供n个线程使用,即进程是最小的管理单元. ...
- Charles安装与使用
Charles是在 Mac 下常用的网络封包截取工具,在做 移动开发时,我们为了调试与服务器端的网络通讯协议,常常需要截取网络封包来分析. Charles 通过将自己设置成系统的网络访问代理服务器,使 ...
- 【转】Python爬虫_示例
爬虫项目:爬取汽车之家新闻资讯 # requests+Beautifulsoup爬取汽车之家新闻 import requests from bs4 import BeautifulSoup res ...
- spark学习(1)--ubuntu14.04集群搭建、配置(jdk)
环境:ubuntu14.04 jdk-8u161-linux-x64.tar.gz 1.文本模式桌面模式切换 ctrl+alt+F6 切换到文本模式 ctrl + alt +F7 /输入命令start ...