📄 txttodata.java
字号:
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2007</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
import java.io.*;
import java.util.Vector;
public class TxtToData
{
public TxtToData()
{
}
public static void main(String[] args)
{
TxtToData ttd = new TxtToData();
if (args != null && args.length >= 2)
{
String infile = args[0];
String outfile = args[1];
Vector lines = new Vector();
String line = null;
try
{
System.out.println("Reading source file :" + infile);
LineNumberReader lr = new LineNumberReader(new FileReader(infile));
while ( (line = lr.readLine()) != null)
{
lines.add(line);
}
lr.close();
int linescount = lines.size();
System.out.println("Number of lines in source file :" + linescount);
System.out.println("Writing destination file :" + outfile);
DataOutputStream dos = new DataOutputStream(new FileOutputStream(outfile));
dos.writeInt(linescount);
for (int i = 0; i < linescount; i++)
{
line = (String) lines.elementAt(i);
dos.writeUTF(line);
}
dos.close();
System.out.println("Done.");
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
else
{
System.out.println("Usage : TxtToData <infile> <outfile>");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -