杏吧有你,春暖花开!马上注册,看更多精彩内容!
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
微信、浏览器扫描下载杏吧APP
用Java写了一个可以批量生成站内链接的小程序,现发布源代码,需要的兄弟们自取初始界面:
导入网址
点击下方按钮,链接存入剪贴板
结果图
代码:
import java.awt.BorderLayout; import java.awt.Toolkit; import java.awt.datatransfer.StringSelection; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.JScrollPane; import javax.swing.JTextArea;
public class LinkGenerator { final static String STRING_ONE = "[url="; final static String STRING_TWO = "]"; final static String STRING_THREE = "[/url]"; private JFrame frame = new JFrame();;
public static void main(String[] args) { try { LinkGenerator lg = new LinkGenerator(); lg.frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); JOptionPane.showMessageDialog(null, e, "WARNING", JOptionPane.WARNING_MESSAGE); } };
public LinkGenerator() { frame.setBounds(100, 100, 500, 400); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTextArea text = new JTextArea(); JScrollPane textScroll = new JScrollPane(text); frame.getContentPane().add(textScroll, BorderLayout.CENTER);
JButton btn = new JButton("Generate Links"); btn.addActionListener(e -> { String[] stringRead = text.getText().split("\n"); Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(generateLink(stringRead)), null); JOptionPane.showMessageDialog(null, "The Links Generated are Saved in the Clipboad", "Task Completed", JOptionPane.INFORMATION_MESSAGE); }); frame.getContentPane().add(btn, BorderLayout.SOUTH); }
static String generateLink(String[] inputString) { StringBuilder sb = new StringBuilder(""); int i = 1; for (String str : inputString) { sb.append(i); sb.append("、"); sb.append(STRING_ONE); sb.append(str); sb.append(STRING_TWO); sb.append(str); sb.append(STRING_THREE); sb.append("\n"); i++; } return sb.toString(); } }
|