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 ...
随机推荐
- 坑爹的 HTTPClient java.lang.NoSuchFieldError: INSTANCE
项目中需要用到httpclient ,maven配置如下 <dependency> <groupId>org.apache.httpcomponents</groupId ...
- 关于Apache Shiro权限框架的一些使用误区的解释
多了不说了,进入正题,shiro是个权限框架提供权限管理等功能,网上的教程一般都是互相抄,比如<shiro:principal property="xxx"/>这个标签 ...
- 启动hive --service metastore &出现Missing Hive Execution Jar: /opt/apache-hive-1.2.0-bin//lib/hive-exec-*.jar
原因:出现上述问题通常是运行hive 在bin/目录下的脚本所致. 解决办法:就是让HIVE_HOME变量指向hive-trunk/build/dist目录,将$HIVE_HOME/bin添加到PAT ...
- docker 批量导出脚本
用for 循环实现 docker imagesREPOSITORY TAG ...
- 关于android编程中service和activity的区别
一. 绝大部分情况下,Service的作用是用来“执行”后台的.耗时的.重要的任务,三者缺一不可,而最重要的原因是第三点:要执行重要的任务. 因为当一个进程启动了Service后,进程的优先级变高了, ...
- 判断点是否在区域的python实现(射线法)
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Date : 2018-10-07 15:49:37 # @Author : Sheldon (thi ...
- vim插件快捷键
@1:winmanager: #1:打开winmanager的快捷键在.vimrc中配置,默认为":WMToggle",使用nmap可以将其映射到其他的命令. #2:netrw快捷 ...
- 高阶函数,map,filter,sorted
Map:对列表中的每个元素进行操作 >>> def f(x): ... return x * x ... >>> map(f, [1, 2, 3, 4, 5, ...
- Python基础(16)_面向对象程序设计(类、继承、派生、组合、接口)
一.面向过程程序设计与面向对象程序设计 面向过程的程序设计:核心是过程,过程就解决问题的步骤,基于该思想设计程序就像是在设计一条流水线,是一种机械式的思维方式 优点:复杂的问题的简单化,流程化 缺点: ...
- 021_在Eclipse Indigo中安装插件hadoop-eclipse-plugin-1.2.1.jar,直接运行wordcount程序
1.工具介绍 Eclipse Idigo.JDK1.7-32bit.hadoop1.2.1.hadoop-eclipse-plugin-1.2.1.jar(自己网上下载) 2.插件安装步骤 1)将ha ...