java高效读取大文件

BufferReader 我们可以使用 BufferReader#readLine 逐行读取数据。 try (BufferedReader fileBufferReader = new BufferedReader(new FileReader(“temp/test.txt”))) {      String fileLineContent;      while ((fileLineContent = fileBufferReader.readLine()) != null) {          // process the line.      }  } catch (FileNotFoundException e) {      e.printStackTrace();  } catch (IOException e) {      e.printStackTrace();  }  Apache Commons IOCommon-IO 中有一个方法 FileUtils#lineIterator可以实现逐行读取方式,使用代码如下:   Stopwatch stopwatch = Stopwatch.createStarted();  LineIterator fileContents = FileUtils.lineIterator(new File(“temp/test.txt”), StandardCharsets.UTF_8.name());  while (fileContents.hasNext()) {      fileContents.nextLine();      //  pass  }  logMemory();  fileContents.close();  stopwatch.stop();  System.out.println(“read all lines spend ” + stopwatch.elapsed(TimeUnit.SECONDS) + ” s”); Java8 stream Java8 Files 类新增了一个 lines,可以返回 Stream我们可以逐行处理数据。   Stopwatch stopwatch = Stopwatch.createStarted();  // lines(Path path, Charset cs)  try (Stream<String> inputStream = Files.lines(Paths.get(“temp/test.txt”), StandardCharsets.UTF_8)) {      inputStream              .filter(str -> str.length() > 5)// 过滤数据              .forEach(o -> {                  // pass do sample logic              });  }  logMemory();  stopwatch.stop();  System.out.println(“read all lines spend ” + stopwatch.elapsed(TimeUnit.SECONDS) + ” s”);  使用这个方法有个好处在于,我们可以方便使用 Stream 链式操作,做一些过滤操作。 注意:这里我们使用 try-with-resources … Read more

el-table 表格头部和单元格字体样式等

el-table 表格头部和单元格字体样式等 <el-table :cell-style=”{color: ‘#666’, fontFamily: ‘Arial’,fontSize:’15px’}” :data=”filteredProductData” :header-cell-style=”{background:’#f0f9eb’, fontFamily:’Helvetica’,fontSize:’14px’}” style=”width: 100%”>

vue中使用el-table调整行间距

在vue中使用el-table但是行间距利用padding或者margin不起作用,是因为display使用的是table属性,所以我们要利用table特性来进行处理。   .el-table { width: 100%; margin-bottom: 20px; &::before { display: none; } .el-table__body { //-webkit-border-horizontal-spacing: 13px; // 水平间距 -webkit-border-vertical-spacing: 10px; // 垂直间距 设置的是行间距 } //以下代码是实现边框效果 thead th { font-size: 14px; color: #575757; &:nth-last-child(2) { border-right: 1px solid rgba(0, 0, 0, 0.1) !important; border-radius: 0 5px 5px 0; right: 1px; } } thead th, .el-table__row … Read more

show-overflow-tooltip 属性和 同时使用文字截断失效

show-overflow-tooltip 属性和<el-link></el-link> 同时使用文字截断失效 4.1在elementui 的 table 组件中 我们可以通过 show-overflow-tooltip 属性来让溢出的文字自动截断   <el-table-column prop=”address” label=”地址” show-overflow-tooltip></el-table-column> 4.2如果表格内容是复杂类型的数据要自己处理的时候可以这样写   <el-table :data=”tableData”> <el-table-column type=”index” width=”50″></el-table-column> <el-table-column prop=”address” label=”地址” show-overflow-tooltip> <template slot-scope=”scope”> <span> {{scope.row.address}} </span> </template> </el-table-column> </el-table> 注意,如果想让show-overflow-tooltip生效一定要加<span></span> 4.3 show-overflow-tooltip 和 <el-link></el-link> 同时使用的时候 文字截断失效了。  

el-table 表头过长换行改为自动截断添加省略号

做前端的时候碰到element ui table组件表头文字太多,自动换行导致表头宽度增加。 看了一些文章,基本都是添加render-header来解决这个问题。 但实际上这个属性已经不被推荐使用了,并且现在用 template + css已经可以很简单的解决这问题了。 <el-table-column> <template v-slot:header> <span class=”header-ellipsis“>LongLongLongLongLongLongText</span> </template> </el-table-column> .header-ellipsis { text-overflow: ellipsis; white-space: nowrap; }

Eclipse离线安装包下载地址

因为在线安装方式可能安装速度很慢(可能是墙等缘故) 离线版本:https://www.eclipse.org/downloads/packages/ 顺着页面往下拖动,找到 Eclipse IDE for Enterprise Java and Web Developers 对应的 Windows x86_64,点击下载即可

Docker运行ubuntu并使用ssh连接

1 获取ubuntu镜像 docker pull ubuntu 2.进入容器内部,并且映射端口号2222:22代表用2222号端口映射容器22端口(ssh通用端口) docker run -it -p 2222:22 ubuntu 因为ubuntu里面什么都没有,先安装需要的,后面需要什么自己apt-get安装 apt-get update apt-get install openssh-server apt-get install vim #为了编辑文件 4.配置root密码 passwd 5.修改ssh配置 vim /etc/ssh/sshd_config 添加 PermitRootLogin yes UsePAM no 6.开启ssh service ssh start 如果启动失败 chmod 700 -R /etc/ssh 7.ssh 连接 ssh root@localhost:23