Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Java program instead of Notepad++ word processing and Powershell

2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article is about how to use Java programs instead of Notepad++ word processing and Powershell. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

As the word processing in Notepad++ is a little complicated, I wonder if it can be handled uniformly with a Java program.

After a try, I found that it was not too complicated, and it was really convenient for Java to deal with all kinds of things. The procedure is as follows:

Note that in RegExp, four backslashes must be used to represent one backslash.

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 aLink = new ArrayList () 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...");}} Thank you for reading! On "how to use Java programs instead of Notepad++ word processing and Powershell" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, you can share it out for more people to see it!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report