当前位置:网站首页>mocklog_ Simulation log
mocklog_ Simulation log
2022-06-22 02:37:00 【Algorithmic Pilgrim】
import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class mock {
/*
* flieName: file name
* num_Row: How many pieces of data are entered
* content: Every one of them / The contents of each row of data
* */
public static void mock2Txt(String flieName, int num_Row, String[] content) {
File file = new File(flieName);
FileWriter fW = null;
BufferedWriter bw = null;
Random random = new Random();
try {
fW = new FileWriter(file, true);
bw = new BufferedWriter(fW);
for (int i = 0; i <= num_Row; i++) {
String cont= content[random.nextInt(content.length)];
bw.write(cont);
bw.newLine();
System.out.println(" The first " + i + " Time input :" + content);
}
bw.flush();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (bw != null) {
try {
bw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (fW != null) {
try {
fW.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
/*
* flieName: file name
* */
public static synchronized ArrayList<String> readTxt2ArrayList(String flieName) throws IOException {
InputStreamReader isr = new InputStreamReader(new FileInputStream(flieName), "UTF-8");
BufferedReader br = new BufferedReader(isr);
ArrayList<String> arrylist = new ArrayList<String>();
String line = null;
int count = 0;
//=====================================================
while ((line = br.readLine()) != null) {
if (!line.equals("0")) {// End of text flag
if (!line.equals("")) {// There is no need to read blank lines
arrylist.add(line);
}
}
count++;
}
//=====================================================
br.close();
isr.close();
if (line !=null) {// Clear variable value
line=null;
count=0;
}
System.out.println(" The first "+count+" The result is :"+line);
System.out.println(arrylist.toArray().length);
//=====================================================
return arrylist;
}
public static void main(String[] args) {
}
}
边栏推荐
- 带你区分几种并行
- Implementation differences between import and require in browser and node environments
- Parallel search DSU
- EMC rectification tips
- Using hook based on xposed framework
- On Monday, I asked the meaning of the | -leaf attribute?
- 使用 OKR 进行 HR 数字化转型
- C# 判断应用是否启动并展示
- How to obtain the comment information of tables and columns in gbase8a database?
- Atguigu---- list rendering
猜你喜欢

EMC radiation emission rectification - principle case analysis

The neo4j skill tree was officially released to help you easily master the neo4j map database

【6. 高精度乘法】

Introduction to Apache ActiveMQ Artemis

Brief introduction to common pigtails of communication pigtails

What programming does a child learn?

Get to know unity3d (project structure, third-party plug-in of probuilder)

EMC rectification tips

Graphacademy course explanation: Fundamentals of neo4j graph data science

Wechat applet film and television comment exchange platform system graduation design (3) background function
随机推荐
MATLAB 学习笔记(4)MATLAB 数组
In 2022, the number of mobile banking users in Q1 will reach 650million, and ESG personal financial product innovation will be strengthened
Starting from the classification of database, I understand the graph database
How to apply PMP project management knowledge?
Kubernetes code generator use
Rely on the robustness of trusted AI to effectively identify deep forgery and help banks fight identity fraud
Chapter 25 digital watermarking technology based on Wavelet Transform
Huayang smart rushes to Shenzhen Stock Exchange: it plans to raise 400million Fosun Weiying as a shareholder
Return to Chengdu to start my software testing career
Penetration testing - logic vulnerability topic
Anaconda historical version download
Chapter 21 design of pavement crack detection and identification system -- matlab deep learning practice
Qt程序怎么实现选中ListWidget中的某一行为默认选中
【5. 高精度减法】
MySQL 递归查找树形结构,这个方法太实用了!
Which Amazon evaluation system is better?
Relative references must start with either “/“, “./“, or “../“.
Global exception handling
Zap grammar sugar
Microblog closes publishing multiple part-time fraud information illegal accounts: how to crack down on data fraud