易截截图软件、单文件、免安装、纯绿色、仅160KB

Java 读写文件 字符分隔

前一段时间因为需要帮别人写了简单的字符串分隔的java小程序,尽管最后没用上,但是作为练习还是不错的。
需求:对于像如下的字符创将其分隔为两列,这样就可以直接粘贴的Excel中各自列,否则一个一个分隔会耗费很多时间。
16 bit microcomputer   16 位微型计算机
3 d distribution   三维分布
4 bit slice processor   4位片处理机
5 reference   5伏基准电压源
a d converter   模拟数字转换器模数转换器
abbreviated code   缓冲存储器
abbreviated dialing   快速呼叫
aberration   象差
abnormal glow discharge   异常辉光放电
abnormal reflections   异常反射
abrasion   磨耗
abrasive   磨料
abrasive dust   磨粉
abrasive jet machining   磨料喷射加工
abrasive jet trimming   磨料喷射蝶
abrasive paste 磨蚀剂
abrasive trimming 研磨蝶
基本思路:按行读取文件,对于每行的字符串从后面找第一个空格,因为汉字一般是连在一起的(对以个别的有数字的暂时不管,分解完成后在手工做这些少数的问题)。从后面的第一个空格分开,将两个子字符串各自写入单独的文件。
代码如下:import java.io.*;
public class MainHT {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
if (args.length == 1) {
MainHT mainHT = new MainHT();
mainHT.ReadFile(args[0]);
}
else{
System.out.println("Usage fileName");
}

}

public void ReadFile(String fileNameandPath)
{
String record = null;
int recCount = 0;
try {
FileReader fr = new FileReader(fileNameandPath);
BufferedReader br = new BufferedReader(fr);
record = new String();

FileWriter fw1 = new FileWriter("one.txt");
PrintWriter pw1= new PrintWriter(fw1);

FileWriter fw2 = new FileWriter("two.txt");
PrintWriter pw2= new PrintWriter(fw2);

while ((record = br.readLine()) != null) {
recCount++;
System.out.print


相关文档:

java基础入门学习笔记(一):bubblesort算法个人学习


public class bubblesort {
 public static void main(String[] args) {
 
   int array[]=new int[]{1,5,9,4,6,2};   
   
   int m;
  
   for(int i=0;i<array.length;i++){
    System.out.print(arra ......

[备份]java中XML解析利器 dom4j的使用简介


要使用dom4j读写XML文档,需要先下载dom4j包,dom4j官方网站在 http://www.dom4j.org/
目前最新dom4j包下载地址: http://nchc.dl.sourceforge.net/sourceforge/dom4j/dom4j-1.6.1.zip
解开后有两个包,仅操作XML文档的话把dom4j-1.6.1.jar加入工程就可以了,如果需要使用XPath的话还需要加入包jaxen-1.1-beta-7.jar.
以下 ......

java事务


事务处理总结
来源:http://space.itpub.net/13956325/viewspace-598381
一、什么是Java 事务
通常的观念认为,事务仅与数据库 相关。
事 务必须服从ISO/IEC所制定的ACID原则。ACID是原子性(atomicity)、一致性(consistency)、隔离性 (isolation)和持久性(durability)的缩写。事务的原子性表示事务 ......

Java可变参数列表

public class TestClass{
public static void main(String args[]){
VarArgs(1, "one");
VarArgs(2, "one", "two");
VarArgs(3, "one", "two", "three");
VarArgs(0); // Attention!
}
static void VarArgs(int nRequired, String... trailing){
System.out.print("Required: " + nRequired + " "); ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号