当前位置:网站首页>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) {
}
}
边栏推荐
- Atguigu---- collect form data
- 如何获取GBase8a数据库中表、列的comment备注信息?
- Show you how to distinguish several kinds of parallelism
- rt_thread的消息队列
- Graphacademy course explanation: introduction to neo4j graph data science
- C ++ Primer 第2章 变量和基本类型 总结
- Huayang smart rushes to Shenzhen Stock Exchange: it plans to raise 400million Fosun Weiying as a shareholder
- 使用 Neo4j 沙箱学习 Neo4j 图数据科学 GDS
- No sleep at noon, sleepy in the afternoon
- In the era of industrial Internet, there is no real center
猜你喜欢

理想L9正式发布:8月底前开始交付 零售价45.98万元

How to use tensorboard add_ histogram

本周一问 | -leaf 这个属性的含义?

Huayang smart rushes to Shenzhen Stock Exchange: it plans to raise 400million Fosun Weiying as a shareholder

GraphAcademy 课程讲解:《Neo4j 图数据科学基础》
![[Chapter 26 medical impact segmentation system based on minimum error method and region growth -- matlab deep learning practical GUI project]](/img/19/18dcc8ed017541d91c52550f48923c.png)
[Chapter 26 medical impact segmentation system based on minimum error method and region growth -- matlab deep learning practical GUI project]

小孩子学什么编程?

华阳智能冲刺深交所:拟募资4亿 复星惟盈是股东

rt_ Message queue of thread

Atguigu---- filter
随机推荐
C# 判断应用是否启动并展示
Idea ---- copy and paste
Minecraft 1.18.2 biochemical 8 module version 1.3 3D objects + more complex villages
使用 OKR 进行 HR 数字化转型
Global exception handling
微软 IE 浏览器于 6 月 15 日被永久关闭
最新发布:Neo4j 图数据科学 GDS 2.0 和 AuraDS GA
OpenJudge NOI 1.13 46:八进制到十进制
The neo4j skill tree was officially released to help you easily master the neo4j map database
Rational Rose installation tutorial
Atguigu---- collect form data
GraphAcademy 课程讲解:《Neo4j 图数据科学简介》
Matlab learning notes (4) matlab array
理想L9正式发布:8月底前开始交付 零售价45.98万元
【5. 高精度减法】
FPGA-Xilinx 7系列FPGA DDR3硬件设计规则
Input system learning ----- inputfilter
Atguigu---- filter
All the knowledge you want to know about the PMP Exam is here
cmake常用命令分类备忘