Use Java programs to replace Notepad++ word processing and Powershell
由于Notepad++里面的文字处理有些复杂,我在想能不能用一个Java程序来统一处理呢?
尝试了一下,发现不太复杂,Java果然处理各种事情都比较方便。程序如下:
注意在RegExp里面,必须用四个反斜杠\\\\代表一个反斜杠\
package com.pwc; import java.io.BufferedReader; import java.io.ByteArrayOutputStream; import java.io.DataInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.net.URL; import java.util.ArrayList; import java.util.regex.Matcher; import java.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/
The above is the detailed content of Use Java programs to replace Notepad++ word processing and Powershell. For more information, please follow other related articles on the PHP Chinese website!

Installation steps of Notepad: 1. Visit the official website to download the latest stable version; 2. Run the installation file and click "Next"; 3. Agree to the license agreement; 4. Select the installation path; 5. Select whether to create a desktop shortcut and start menu folder; 6. Complete the installation and start Notepad.

Notepad is free and open source, and is licensed under the GPLv2. 1. Anyone can use and modify Notepad for free. 2. When used by the enterprise, any modification or extension must be published in GPLv2. 3. The use of commercial products must comply with GPLv2, including public source code.

Notepad originatesfromFrance,createdbyDonHo.1)France'sfocusoneducationandtechnologyfostersinnovation,reflectedinNotepad 'sdesign.2)Theopen-sourceethosalignswithFrenchvaluesofsharingknowledge.3)EfficiencyandperformancearehallmarksofFrenchengineering

Notepad sustainsitselffinanciallythroughdonations,sponsorships,andapluginecosystem.1)Donationsfromusersprovidethemainincome,keepingthetoolfreeandfosteringcommunity.2)Sponsorshipsfromcompaniesofferastableincomewhilemaintainingindependence.3)Apluginec

Free alternatives to Notepad include VisualStudioCode, SublimeText, and Atom. 1. VisualStudioCode supports multiple languages and enhances features through extensions. 2. SublimeText provides an evaluation version, which is fast and has a simple interface. 3.Atom is known for its high customizability and is suitable for personalized needs.

Notepad is a free and open source text editor. 1) Free use lowers the entry threshold, 2) Open source features are implemented through the GPLv2 license, allowing the viewing, modifying and distributing source code, promoting community participation and software evolution.

Notepad is a free text editor for Windows, which offers a variety of features such as: 1) syntax highlighting, 2) autocomplete, 3) macro recording, 4) plug-in extensions, 5) customizable interfaces and settings.

Notepad itself does not have automatic layout function. We can use a third-party text editor, such as Sublime Text, to perform the following steps to achieve automatic typography: 1. Install and open the text editor. 2. Open the file that needs to be automatically typed. 3. Find and select the automatic layout function. 4. The editor will automatically type the text. 5. You can customize the layout rules as needed. Automatic typography can save time and ensure text consistency and professionalism.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Zend Studio 13.0.1
Powerful PHP integrated development environment

Notepad++7.3.1
Easy-to-use and free code editor

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.