用J*a程序代替Notepad++的文字处理和Powershell

用Java程序代替Notepad++的文字处理和Powershell

由于notepad++里面的文字处理有些复杂,我在想能不能用一个j*a程序来统一处理呢?

尝试了一下,发现不太复杂,J*a果然处理各种事情都比较方便。程序如下:

注意在RegExp里面,必须用四个反斜杠\代表一个反斜杠

PLC编程入门基础知识 中文doc版 PLC编程入门基础知识 中文doc版

可编程序控制器,英文称Programmable Controller,简称PC。但由于PC容易和个人计算机(Personal Computer)混淆,故人们仍习惯地用PLC作为可编程序控制器的缩写。它是一个以微处理器为核心的数字运算操作的电子系统装置,专为在工业现场应用而设计,它采用可编程序的存储器,用以在其内部存储执行逻辑运算、顺序控制、定时/计数和算术运算等操作指令,并通过数字式或模拟式的输入、输出接口,控制各种类型的机械或生产过程。本平台提供PLC编程入门基础知识下载,需要的朋友们下载看看吧!

PLC编程入门基础知识 中文doc版 1 查看详情 PLC编程入门基础知识 中文doc版
package com.pwc;
import j*a.io.BufferedReader;
import j*a.io.ByteArrayOutputStream;
import j*a.io.DataInputStream;
import j*a.io.File;
import j*a.io.FileInputStream;
import j*a.io.FileOutputStream;
import j*a.io.IOException;
import j*a.io.InputStreamReader;
import j*a.net.URL;
import j*a.util.ArrayList;
import j*a.util.regex.Matcher;
import j*a.util.regex.Pattern;
public class WechatMomentDownload {
    
    public static String jsonFile = "C:\Download\exported_sns_gary.json";
    public static String outputFolder = "C:\Download\gary_pic\";
    public static void main(String[] args) throws IOException {
        BufferedReader reader = null;
        String sLine = "";
        String sContent = "";
        String sLink = "";
        URL url = null;
        String outputFile = "";
        ArrayList<String> aLink = new ArrayList<String>();
        String Regex1 = "CDATA\[http\:\\\/\\\/(sh)?mmsns([^]]*)\/0\]";
        
        reader = new BufferedReader(
                new InputStreamReader(new FileInputStream(new File(jsonFile)), "UTF-8"));
        if (reader != null) {
            while ((sLine = reader.readLine()) != null) {
                sContent = sContent + sLine;
            }
            reader.close();
        }
        
        Pattern pattern = Pattern.compile(Regex1);
        Matcher matcher = pattern.matcher(sContent);
        int count = 0;
        
        System.out.println("Start processing...");
        while(matcher.find()) {
            count++;
            sLink = sContent.substring(matcher.start() + 6, matcher.end() - 1);
            sLink = sLink.replaceAll("\\/", "/");
            aLink.add(sLink);
         }
        
        System.out.println(count + " pictures were found");
        
        for (String sLinkTemp : aLink) {
            url = new URL(sLinkTemp);
            DataInputStream dataInputStream = new DataInputStream(url.openStream());
            
            outputFile = outputFolder + count + ".jpg";
            FileOutputStream fileOutputStream = new FileOutputStream(new File(outputFile));
            ByteArrayOutputStream output = new ByteArrayOutputStream();
            System.out.println("Downloading " + sLinkTemp + " to file " + outputFile);
            
            byte[] buffer = new byte[1024];
            int length;
 
            while ((length = dataInputStream.read(buffer)) > 0) {
                output.write(buffer, 0, length);
            }
            fileOutputStream.write(output.toByteArray());
            dataInputStream.close();
            fileOutputStream.close();
        
            count--;
        }
        
        System.out.println("End of processing...");
    }
}

更多notepad教程,请访问notepad使用教程栏目:https://www.php.cn/tool/notepad/

以上就是用J*a程序代替Notepad++的文字处理和Powershell的详细内容,更多请关注其它相关文章!

本文转自网络,如有侵权请联系客服删除。