如何排版TXT文件

如何排版TXT文件,第1张

排版TXT文件:

1、选中岁竖要排版的文件,点菜单上的格式,进行字体,字形,大小的处理。

2、        将文件内容复制到WORD中进行编辑乎悄大排版运春。

数据处理方面的凯纳事返团情,可以考虑使用Data.olllo数盯世没据助手这样的工具,超大EXCEL、CSV、TXT数据文件排序 *** 作很简单,还可以随时各个文件格式的转换。

import java.io.File

import java.io.FileWriter

import java.io.IOException

import java.util.ArrayList

import java.util.Collections

import java.util.List

import java.util.Scanner

public class Merge {

private String path

private String[] fileName

private List<Card>list

public Merge(String path) {

this.path = path

this.setFile()

this.setList()

Collections.sort(list)

}

private void setFile() {

File f = new File(path)

fileName = f.list()

for (int i = 0i <fileName.lengthi++) {

fileName[i] = path + fileName[i]

}

}

private void setList() {

list = new ArrayList<Card>()

try {

for (int i = 0i <哗竖 fileName.lengthi++) {

File in = new File(fileName[i])

Scanner sc = new Scanner(in)

while (sc.hasNextLine()) {

long id = sc.nextLong()

long pwd = sc.nextLong()

int check = sc.nextInt()

list.add(new Card(id, pwd, check))

}

}

} catch (Exception e) {

e.printStackTrace()

}

}

public void write(String url) {

int size = list.size()

Card c

try {

FileWriter out = new FileWriter(url)

for (int i = 0i <size / 10i++) {

for (int j = 0j <10j++) {

c =list.get(i*10+j)

out.write(c.id+" ")

}

out.write("\r\n")

for (int j = 0j <10j++) {

c =list.get(i*10+j)

out.write(c.pwd+" ")

}

out.write("\r\n")

for (int j = 0j <10j++) {

c =list.get(i*10+j)

out.write(c.check+"")

}

out.write("\r\n")

}

int i = size/10

for (int j = 0j <size%10j++) {

c =list.get(i*10+j)

out.write(c.id+" ")

}

out.write("\r\n")

for (int j = 0j <size%10j++) {

c =list.get(i*10+j)

out.write(c.pwd+" ")

}

out.write("\r\n"乱大大)

for (int j = 0j <仿孙 size%10j++) {

c =list.get(i*10+j)

out.write(c.check+"")

}

out.flush()

out.close()

} catch (IOException e) {

e.printStackTrace()

}

}

public static void main(String[] args) throws Exception {

Merge m = new Merge("F:/test/")//txt文件所在的目录,请按照此格式,不要忘记最后的/

m.write("F:/test/a.txt")//最后要写入的txt的路径名

}

private class Card implements Comparable<Card>{

private long id

private long pwd

private int check

public Card(long id, long pwd, int check) {

super()

this.id = id

this.pwd = pwd

this.check = check

}

public String toString() {

return id + "," + pwd + "," + check

}

public int compareTo(Card u) {

long i = u.id - this.id

if (i == 0) {

return 0

} else if (i >0) {

return 1

} else {

return -1

}

}

}

}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/tougao/8206075.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-14
下一篇 2023-04-14

发表评论

登录后才能评论

评论列表(0条)

保存