`
jqallen
  • 浏览: 3850 次
  • 性别: Icon_minigender_1
  • 来自: 成都
文章分类
社区版块
存档分类
最新评论

Java计算文件校验和组件FileChecksum(附可运行程序下载)

阅读更多
1. 测试程序最终截图

2. 定义组件支持的算法
package org.file.util.checksum;

/**
 * @author ALLEN
 * <br/>Define the checksum calculation algorithm
 * <br/>Support <b>{ Adler32, CRC32, MD2, MD5, SHA, SHA-1, SHA-256, SHA-384, SHA-512 }</b>
 */
public enum Algorithm {
	
	Adler32, /* Adler32 Algorithm */
	CRC32, /* CRC32 Algorithm */
	MD2, /* MD2 Algorithm */
	MD5, /* MD5 Algorithm */
	SHA, /* SHA Algorithm */
	SHA1, /* SHA-1 Algorithm */
	SHA256, /* SHA-256 Algorithm */
	SHA384, /* SHA-384 Algorithm */
	SHA512 /* SHA-512 Algorithm */
	
}

3. 定义回掉函数,作为组件监听器
package org.file.util.checksum;

import java.util.Properties;

/**
 * @author ALLEN
 * <br/>Define the checksum progress listener
 */
public interface ProgressListener {
	
	/**
	 * Define the progress listener method which can read the calculation progress
	 * @param finished
	 * 				the total bytes finished reading
	 * @param total
	 * 				the total bytes of data
	 * @param start
	 * 				the start time of progress
	 * @param current
	 * 				the current time of progress
	 * @param properties
	 * 				the result properties of checksum
	 * 				<br/>properties key should be in <b>{ Name, Path, Size, LastModified, Hidden, 
	 * 				Readable, Writable, Executable, Time, Adler32, CRC32, MD2, MD5, SHA, 
	 * 				SHA-1, SHA-256, SHA-384, SHA-512 }<b/>
	 */
	public void progress(long finished, long total, long start, long current, Properties properties);
	
}

4. 核心算法实现
package org.file.util.checksum;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.security.MessageDigest;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.zip.Adler32;
import java.util.zip.CRC32;
import java.util.zip.Checksum;

/**
 * @author ALLEN
 * <br/>Calculate the checksum of the specified file
 */
public class FileChecksum implements Runnable {
	
	/**
	 * Define hex digit value <b>{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F }</b>
	 */
	private static final char hexDigits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
	
	/**
	 * Define the default buffer size { 2 << 19 = 1MB }
	 */
	private static final int DEFAULT_BUFFER_SIZE = 2 << 19;
	
	/**
	 * Define the default file block { 500 }
	 */
	private static final int DEFAULT_FILE_BLOCK = 500;
	
	/**
	 * Define the default date format pattern
	 */
	private static final String PATTERN = "ZZ F yyyy-MM-dd HH:mm:ss:SSS";

	/**
	 * Define the { f: Algorithm -> String } hash map table
	 */
	private static final Map<Algorithm, String> hashMap = new HashMap<Algorithm, String>();
	
	/**
	 * Initialize the { f: Algorithm -> String } hash map table
	 */
	static {
		hashMap.clear();
		hashMap.put(Algorithm.Adler32, "java.util.zip.Adler32");
		hashMap.put(Algorithm.CRC32, "java.util.zip.CRC32");
		hashMap.put(Algorithm.MD2, "MD2");
		hashMap.put(Algorithm.MD5, "MD5");
		hashMap.put(Algorithm.SHA, "SHA");
		hashMap.put(Algorithm.SHA1, "SHA-1");
		hashMap.put(Algorithm.SHA256, "SHA-256");
		hashMap.put(Algorithm.SHA384, "SHA-384");
		hashMap.put(Algorithm.SHA512, "SHA-512");
	}
	
	/**
	 * Define the file instance
	 */
	private File file;
	
	/**
	 * Define the checksum algorithm collection
	 */
	private Algorithm[] algorithms;
	
	/**
	 * Define the default date format pattern instance
	 */
	private final SimpleDateFormat sdf = new SimpleDateFormat(PATTERN);
	
	/**
	 * Define the checksum calculation collection
	 */
	private final List<Checksum> checksums = new LinkedList<Checksum>();
	private final List<MessageDigest> messageDigests = new LinkedList<MessageDigest>();
	
	/**
	 * Define the configuration parameters
	 */
	private final Object[] config = {false, null, null};
	
	/**
	 * Define the result properties collection
	 */
	private final Properties properties = new Properties();
	
	/**
	 * Define the progress listener linked list collection
	 */
	private final List<ProgressListener> listeners = new LinkedList<ProgressListener>();
	
	/**
	 * The default constructor
	 * @param file
	 * 			the file instance
	 * @param algorithms
	 * 			the checksum algorithm collection
	 */
	private FileChecksum(File file, Algorithm... algorithms) {
		this.file = file;
		this.algorithms = algorithms;
		this.init();
	}
	
	/**
	 * Return an instance of FileChecksum type
	 * @param absolutePath
	 * 				the absolute path of the specified file
	 * @param algorithms
	 * 				the checksum algorithm collection
	 * @return
	 * 				an instance of FileChecksum type
	 */
	public static FileChecksum getInstance(String absolutePath, Algorithm... algorithms) {
		String separator = System.getProperty("file.separator");
		int lastPos = absolutePath.lastIndexOf(separator);
		String path = absolutePath.substring(0, lastPos);
		String name = absolutePath.substring(lastPos + 1, absolutePath.length());
		return getInstance(path, name, algorithms);
	}
	
	/**
	 * Return an instance of FileChecksum type
	 * @param path
	 * 			the path of the specified file
	 * @param name
	 * 			the name of the specified file
	 * @param algorithms
	 * 			the checksum algorithm collection
	 * @return
	 * 			an instance of FileChecksum type
	 */
	public static FileChecksum getInstance(String path, String name, Algorithm... algorithms) {
		return getInstance(new File(path, name), algorithms);
	}
	
	/**
	 * Return an instance of FileChecksum type
	 * @param file
	 * 			the file instance of the specified file
	 * @param algorithms
	 * 			the checksum algorithm collection
	 * @return
	 * 			an instance of FileChecksum type
	 */
	public static FileChecksum getInstance(File file, Algorithm... algorithms) {
		return new FileChecksum(file, algorithms);
	}
	
	/**
	 * Convert bytes array to string
	 * @param bytes
	 * 			the bytes array
	 * @return
	 * 			the string of bytes array
	 */
	private static String bytesToString(byte[] bytes) {
		StringBuffer result = new StringBuffer(2 * bytes.length);
		for (int i = 0; i < bytes.length; i++)
			result.append(hexDigits[(bytes[i] & 0xF0) >> 4]).append(hexDigits[bytes[i] & 0x0F]);
		return result.toString().toUpperCase();
	}
	
	/**
	 * Convert long to string
	 * @param checksum
	 * 			the long value
	 * @return
	 * 			the string of long
	 */
	private static String longToString(long checksum) {
		return Long.toHexString(checksum).toUpperCase();
	}
	
	/**
	 * Initialize the calculation component
	 */
	private void init() {
		// clear
		this.checksums.clear();
		this.messageDigests.clear();
		this.listeners.clear();
		// parser the algorithms
		try {
			for (int i = 0; i < this.algorithms.length; i++) {
				String algorithm = hashMap.get(this.algorithms[i]);
				if (this.algorithms[i] == null)
					continue;
				else if (this.algorithms[i] == Algorithm.Adler32)
					this.checksums.add((Adler32)Class.forName(algorithm).newInstance());
				else if (this.algorithms[i] == Algorithm.CRC32)
					this.checksums.add((CRC32)Class.forName(algorithm).newInstance());
				else
					this.messageDigests.add(MessageDigest.getInstance(algorithm));
			}
		} catch (Exception e) {
			;
		}
	}
	
	/**
	 * Calculate the checksum of the specified file
	 */
	private void process() {
		// assign buffer size
		final long fileLength = this.file.length();
		int bufferSize = -1;
		if (fileLength < 0L)
			return;
		else if (fileLength < DEFAULT_FILE_BLOCK)
			bufferSize = (int)fileLength;
		else if (Math.round((double)fileLength / DEFAULT_FILE_BLOCK) < DEFAULT_BUFFER_SIZE)
			bufferSize = DEFAULT_BUFFER_SIZE;
		else
			bufferSize = (int)Math.round((double)fileLength / DEFAULT_FILE_BLOCK);
		// set file properties
		this.properties.setProperty("Name", this.file.getName());
		this.properties.setProperty("Path", this.file.getAbsolutePath());
		this.properties.setProperty("Size", String.valueOf(fileLength));
		this.properties.setProperty("LastModified", this.sdf.format(new Date(this.file.lastModified())));
		this.properties.setProperty("Hidden", String.valueOf(this.file.isHidden()));
		this.properties.setProperty("Readable", String.valueOf(this.file.canRead()));
		this.properties.setProperty("Writable", String.valueOf(this.file.canWrite()));
		this.properties.setProperty("Executable", String.valueOf(this.file.canExecute()));
		// calculate file checksum
		try {
			BufferedInputStream input = new BufferedInputStream(new FileInputStream(this.file), bufferSize);
			byte[] buffer = new byte[bufferSize];
			int length = -1;
			long finished = 0L;
			long start, current;
			start = current = System.currentTimeMillis();
			while ((finished < fileLength) && (length = input.read(buffer, 0, bufferSize)) != -1) {
				finished += length;
				// update checksums
				for (int i = 0; i < this.checksums.size(); i++) {
					Checksum checksum = this.checksums.get(i);
					checksum.update(buffer, 0, length);
					if (checksum instanceof Adler32)
						this.properties.setProperty("Adler32", longToString(checksum.getValue()));
					else if (checksum instanceof CRC32)
						this.properties.setProperty("CRC32", longToString(checksum.getValue()));
					else
						continue;
				}
				// update message digests
				for (int i = 0; i < this.messageDigests.size(); i++) {
					MessageDigest messageDigest = this.messageDigests.get(i);
					messageDigest.update(buffer, 0, length);
					this.properties.setProperty(messageDigest.getAlgorithm(), bytesToString(((MessageDigest)messageDigest.clone()).digest()));
				}
				// update current calculation time
				current = System.currentTimeMillis();
				// notify progress listeners
				synchronized (this.listeners) {
					for (ProgressListener listener : this.listeners)
						listener.progress(finished, fileLength, start, current, this.properties);
				}
			}
			this.properties.setProperty("Time", String.valueOf(current - start));
			input.close();
		} catch (Exception e) {
			;
		}
	}
	
	/**
	 * Register a new progress listener into the listeners linked list
	 * @param listener
	 * 			the ProgressListener instance
	 */
	public void registerProgressListener(ProgressListener listener) {
		if (listener != null)
			synchronized (this.listeners) {
				this.listeners.add(listener);
			}
	}
	
	/**
	 * Remove a progress listener from the listeners linked list
	 * @param listener
	 * 			the ProgressListener instance
	 */
	public void removeProgressListener(ProgressListener listener) {
		if (listener != null)
			synchronized (this.listeners) {
				this.listeners.remove(listener);
			}
	}
	
	/**
	 * Set the properties XML file parameters
	 */
	public void setDefaultXMLConfig() {
		synchronized (this.config) {
			this.config[0] = true;
			this.config[1] = "CHECKSUM_" + longToString(System.nanoTime()) + ".XML";
			this.config[2] = null;
		}
	}
	
	/**
	 * Set the properties XML file parameters
	 * @param comment
	 * 			the comment of XML file
	 */
	public void setDefaultXMLConfig(String comment) {
		synchronized (this.config) {
			this.config[0] = true;
			this.config[1] = "CHECKSUM_" + longToString(System.nanoTime()) + ".XML";
			this.config[2] = comment;
		}
	}
	
	/**
	 * Set the properties XML file parameters
	 * @param absolutePath
	 * 			the absolute path of the destination file
	 * @param comment
	 * 			the comment of XML file
	 */
	public void setDefaultXMLConfig(String absolutePath, String comment) {
		synchronized (this.config) {
			this.config[0] = true;
			this.config[1] = absolutePath;
			this.config[2] = comment;
		}
	}
	
	/**
	 * Start the process thread to run
	 */
	public synchronized void execute() {
		new Thread(this).start();
	}
	
	/* (non-Javadoc)
	 * @see java.lang.Runnable#run()
	 */
	public void run() {
		synchronized (this) {
			this.process();
			try {
				if ((Boolean)this.config[0])
					this.properties.storeToXML(new FileOutputStream((String)this.config[1], false), (String)this.config[2], "UTF-8");
			} catch (Exception e) {
				;
			}
		}
	}
	
}

5. 核心测试代码
package org.file.util.checksum;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Properties;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;

/**
 * @author ALLEN
 * <br/>Checksum test case
 */
public class ChecksumTest extends JFrame implements ProgressListener {
	
	private static final long serialVersionUID = -3707959572261992767L;
	
	private static String path = null;
	private static FileChecksum fc;
	private static ChecksumTest self;
	
	private JLabel title;
	private JProgressBar progress;
	private JLabel label1;
	private JLabel label2;
	private JLabel label3;
	private JLabel label4;
	private JLabel label5;
	private JLabel label6;
	private JLabel label7;
	private JLabel label8;
	private JLabel label9;
	private static JButton broswer;
	private static JButton calculate;

	public ChecksumTest() {
		
		super("JAVA SDK FILECHECKSUM");
		self = this;
		this.setIconImage(new ImageIcon(this.getClass().getResource("/org/data/resource/images/title.png")).getImage());
		
		try {
			UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
		} catch (Exception e) {
			;
		}
		
		JPanel jPanel = new JPanel(null);
		jPanel.setOpaque(true);
		jPanel.setBackground(Color.ORANGE);
		jPanel.setPreferredSize(new Dimension(330, 267));
		
		this.title = new JLabel("*** JAVA SDK FILECHECKSUM 1.0.0.0 TESTCASE ***", JLabel.CENTER);
		this.title.setBounds(new Rectangle(10, 3, 310, 25));
		
		this.progress = new JProgressBar();
		this.progress.setStringPainted(true);
		this.progress.setValue(0);
		this.progress.setString("Waiting for selecting ......");
		this.progress.setBounds(new Rectangle(10, 25, 310, 25));
		
		this.label1 = new JLabel("[ Name ]", JLabel.CENTER);
		this.label1.setBounds(new Rectangle(10, 50, 310, 25));
		
		this.label2 = new JLabel("[ Modified ]", JLabel.CENTER);
		this.label2.setBounds(new Rectangle(10, 70, 310, 25));
		
		this.label3 = new JLabel("[ Readable ]    [ Writable ]", JLabel.CENTER);
		this.label3.setBounds(new Rectangle(10, 90, 310, 25));
		
		this.label4 = new JLabel("[ Executable ]    [ Hidden ]", JLabel.CENTER);
		this.label4.setBounds(new Rectangle(10, 110, 310, 25));
		
		this.label5 = new JLabel("[ Size ]    [ Time ]", JLabel.CENTER);
		this.label5.setBounds(new Rectangle(10, 130, 310, 25));
		
		this.label6 = new JLabel("[ Speed ]    [ Remain ]", JLabel.CENTER);
		this.label6.setBounds(new Rectangle(10, 150, 310, 25));
		
		this.label7 = new JLabel("[ Adler32 ]    [ CRC32 ]", JLabel.CENTER);
		this.label7.setBounds(new Rectangle(10, 170, 310, 25));
		
		this.label8 = new JLabel("[ MD5 ]", JLabel.CENTER);
		this.label8.setBounds(new Rectangle(10, 190, 310, 25));
		
		this.label9 = new JLabel("[ SHA-1 ]", JLabel.CENTER);
		this.label9.setBounds(new Rectangle(5, 210, 320, 25));
		
		broswer = new JButton("Broswer");
		broswer.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				JFileChooser chooser = new JFileChooser();
				chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
				int returnVal = chooser.showOpenDialog(null);
				if(returnVal == JFileChooser.APPROVE_OPTION) {
					path = chooser.getSelectedFile().getAbsolutePath();
				}
			}
		});
		broswer.setBounds(new Rectangle(10, 233, 150, 25));
		
		calculate = new JButton("Calculate");
		calculate.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if (path != null) {
					fc = FileChecksum.getInstance(path, Algorithm.Adler32, Algorithm.CRC32, Algorithm.MD5, Algorithm.SHA1);
					fc.registerProgressListener(self);
					fc.setDefaultXMLConfig("GENERATED BY JAVA SDK FILECHECKSUM 1.0.0.0");
					broswer.setEnabled(false);
					calculate.setEnabled(false);
					fc.execute();
				}
			}
		});
		calculate.setBounds(new Rectangle(168, 233, 150, 25));
		
		jPanel.add(this.title);
		jPanel.add(this.progress);
		jPanel.add(this.label1);
		jPanel.add(this.label2);
		jPanel.add(this.label3);
		jPanel.add(this.label4);
		jPanel.add(this.label5);
		jPanel.add(this.label6);
		jPanel.add(this.label7);
		jPanel.add(this.label8);
		jPanel.add(this.label9);
		jPanel.add(broswer);
		jPanel.add(calculate);
		
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setContentPane(jPanel);
		this.setSize(new Dimension(330, 267));
		this.setResizable(false);
		this.setVisible(true);
		Dimension resolution = Toolkit.getDefaultToolkit().getScreenSize();
		this.setLocation((int)resolution.getWidth() / 2 - 165, (int)resolution.getHeight() / 2 - 133);
		this.pack();
	}

	public void progress(long finished, long total, long start, long current, Properties properties) {
		float percent = (float) finished * 100 / total;
		long cost = current - start;
		double speed = (double)finished * 0.9765625 / cost;
		long remain = cost * (total - finished) / finished;
		this.progress.setValue((int)percent);
		this.progress.setString(String.format("%.2f%%", percent));
		this.label1.setText(String.format("[ Name: %s ]", properties.getProperty("Name")));
		this.label2.setText(String.format("[ Modified: %s ]", properties.getProperty("LastModified")));
		this.label3.setText(String.format("[ Readable: %s ]    [ Writable: %s ]", properties.getProperty("Readable"), properties.getProperty("Writable")));
		this.label4.setText(String.format("[ Executable: %s ]    [ Hidden: %s ]", properties.getProperty("Readable"), properties.getProperty("Hidden")));
		this.label5.setText(String.format("[ Size: %d Bytes ]    [ Time: %d ms ]", total, cost));
		this.label6.setText(String.format("[ Speed: %.2f Bps ]    [ Remain: %d ms ]", speed, remain));
		this.label7.setText(String.format("[ Adler32: %s ]    [ CRC32: %s ]", properties.getProperty("Adler32"), properties.getProperty("CRC32")));
		this.label8.setText(String.format("[ MD5: %s ]", properties.getProperty("MD5")));
		this.label9.setText(String.format("[ %s ]", properties.getProperty("SHA-1")));
		if (finished == total) {
			broswer.setEnabled(true);
			calculate.setEnabled(true);
		}
	}
	
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {   
				com.sun.awt.AWTUtilities.setWindowOpacity(new ChecksumTest(), 1.00f);   
			}   
		}); 
	}

}
  • 大小: 116.5 KB
2
1
分享到:
评论

相关推荐

    textern-0.8-1.el8.x64-86.rpm.tar.gz

    1、文件说明: Centos8操作系统textern-0.8-1.el8.rpm以及相关依赖,全打包为一个tar.gz压缩包 2、安装指令: #Step1、解压 tar -zxvf textern-0.8-1.el8.tar.gz #Step2、进入解压后的目录,执行安装 sudo rpm -ivh *.rpm

    基于STM32的循迹避障小车资料源码(高分项目)

    基于STM32的循迹避障小车资料源码(高分项目),个人大四的毕业设计、经导师指导并认可通过的高分设计项目,评审分99分,代码完整确保可以运行,小白也可以亲自搞定,主要针对计算机相关专业的正在做毕设的学生和需要项目实战练习的学习者,也可作为课程设计、期末大作业。 基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(

    金属板卷自动捆扎机器step_三维3D设计图纸_包括零件图_机械3D图可修改打包下载_三维3D设计图纸_包括零件图_机械3D图可修改打包下载.zip

    金属板卷自动捆扎机器step_三维3D设计图纸_包括零件图_机械3D图可修改打包下载_三维3D设计图纸_包括零件图_机械3D图可修改打包下载.zip

    【SSM框架详解】全网最全的SSM详解

    内容概要:本文详细介绍了SSM框架(Spring、SpringMVC、MyBatis)的相关知识,涵盖Maven项目管理工具、前端开发技术、HTTP协议及Tomcat服务器等内容。文章首先讲解了SSM框架的组成,包括Spring的IOC、DI、AOP等功能,SpringMVC的请求处理流程以及MyBatis的数据操作。接着介绍了Maven作为项目管理工具的作用,如依赖管理和项目构建,并详细描述了Maven的配置文件pom.xml的使用方法。此外,还探讨了HTTP协议的特点、请求响应格式,以及Web服务器Tomcat的基本概念和工作原理。最后,文章对前端开发技术进行了概述,包括HTML、CSS、JavaScript等基础知识,并简要介绍了Ajax技术。 适合人群:具备一定编程基础,特别是Java开发经验的研发人员,尤其是那些正在学习或使用SSM框架进行Web开发的工程师。 使用场景及目标:①理解SSM框架的工作原理及其各组成部分的功能;②掌握Maven的使用,包括项目创建、依赖管理、生命周期等;③熟悉HTTP协议的请求响应机制,能够处理常见的HTTP请求和响应;④掌握前端开发技术,如HTML、CSS、JavaScript等,能够进行简单的前端页面开发;⑤了解Tomcat服务器的工作原理及其配置方法。 阅读建议:本文内容丰富,涵盖了从后端到前端的多个方面,建议读者在学习过程中结合实际项目进行实践,尤其是在Maven项目管理和SSM框架的具体应用上,多动手操作,加深理解。同时,对于HTTP协议和前端开发技术,可以通过实际的网络请求和页面开发来巩固所学知识。

    JAVA源码 + SpringBoot+vue+mysql 漫画天堂网 + 数据库 + 文档

    本系统以用户与管理员两类人,作为目标用户,其中用户主要功能包含用户的注册与登录,查看漫画信息进行订阅等,对账号相关信息的修改;管理员主要功能包括了对用户信息、漫画信息、订阅信息、更新通知、在线留言、社区互动等管理;管理员可以实现最高权限级别的全系统管理。 内含文档,可轻松上手。

    工业缺陷检测领域的NEU-DET数据集及其深度学习应用

    内容概要:本文详细介绍了NEU-DET数据集,这是一个包含六种常见表面缺陷(如涂层剥落、油污、锈蚀等)的1800张灰度图像的数据集。数据集分为训练集和测试集,分别为1620张和180张。文中探讨了数据集的特点,如灰度图像的优势、标注信息的重要性以及合理的数据集划分。此外,文章展示了如何使用Python读取标注信息,并提供了使用Keras和PyTorch搭建卷积神经网络(CNN)和Faster R-CNN模型的具体代码示例,用于缺陷分类和目标检测任务。通过数据增强技术和模型优化,可以在工业缺陷检测中取得较好的效果。 适合人群:从事工业缺陷检测、计算机视觉、机器学习等相关领域的研究人员和技术人员。 使用场景及目标:适用于希望利用深度学习技术进行表面缺陷检测的研究人员。具体应用场景包括但不限于产品质量检测、自动化生产线监控等。目标是帮助用户理解和掌握如何使用NEU-DET数据集进行模型训练和评估,提高缺陷检测的准确性。 其他说明:文中提到的数据集和代码示例可以帮助初学者快速入门,同时也为高级用户提供了一些优化建议,如使用预训练模型、调整损失函数权重等。

    基于Qt/CPP的多平台二维图形编辑器:功能实现与技术细节

    内容概要:本文详细介绍了使用Qt/C++开发的一款多平台二维图形编辑器。该编辑器旨在提供简单直观的图形可视化编辑体验,主要功能包括创建和参数化图形、支持多种图类型、多样化的边与节点端口、自定义属性、动态维护交换列表、搜索功能、自动布局与导出、以及多种文件格式的支持。作者分享了项目的实现路径和技术细节,如通过QGraphicsView框架实现图形绘制、利用GraphViz引擎进行自动布局、采用QProcess处理跨平台进程通信、以及性能优化技巧等。 适合人群:对图形编辑器开发感兴趣的研发人员,尤其是熟悉或想要深入了解Qt/C++框架的开发者。 使用场景及目标:适用于需要开发或改进图形编辑工具的技术团队,帮助他们理解和掌握Qt/C++在图形编辑领域的应用,提高开发效率和产品质量。 其他说明:文中不仅展示了具体的代码片段,还分享了许多实用的经验和技巧,如避免性能瓶颈的方法、处理跨平台兼容性的注意事项等。这对于希望深入研究图形编辑技术和Qt/C++框架的开发者来说是非常宝贵的参考资料。

    A股600000浦发银行秒级训练数据集

    股票代码:A股600000浦发银行 2023年-2024年2年秒级数据,可用作训练和回测 数据内容: 时间戳(间隔10-12秒,精确到秒) 买/卖成交量 成交价 开/收盘价 最高/低价 另有类似的大盘秒级数据

    JAVA源码 + SpringBoot+vue+mysql 高校实验室预约系统 + 数据库 + 文档

    内含文档,可轻松上手。

    电路仿真:频率响应分析.zip

    电子仿真教程,从基础到精通,每个压缩包15篇教程,每篇教程5000字以上。

    冲击试验机sw22_三维3D设计图纸_包括零件图_机械3D图可修改打包下载_三维3D设计图纸_包括零件图_机械3D图可修改打包下载.zip

    冲击试验机sw22_三维3D设计图纸_包括零件图_机械3D图可修改打包下载_三维3D设计图纸_包括零件图_机械3D图可修改打包下载.zip

    各院校专业录取分数线.zip

    各院校专业录取分数线.zip

    电力电子领域逆变器VSG阻抗建模与扫频法验证的技术详解及应用

    内容概要:本文深入探讨了逆变器虚拟同步控制(VSG)技术中的阻抗建模及其验证方法。首先介绍了VSG的基本概念和技术背景,强调了正负序阻抗对系统稳定性和电能质量的影响。随后详细讲解了阻抗建模的理论基础,包括正负序阻抗的计算方法和虚拟同步发电机的序阻抗建模。接着阐述了阻抗扫描的具体步骤,包括扫描范围、点数设置以及通过扫频法在不同频率下注入小信号并测量响应的方法。文中提供了详细的Python和MATLAB代码示例,帮助读者理解和实现阻抗建模和扫描验证。最后,通过对比实测阻抗曲线和理论模型,讨论了常见问题及解决方法。 适合人群:从事电力电子、电力系统稳定性和控制的研究人员和工程师,尤其是对VSG技术和阻抗建模感兴趣的读者。 使用场景及目标:适用于需要评估逆变器在不同工况下的电气特性,确保电力系统稳定性和优化电能质量的研究和工程实践中。主要目标是掌握VSG阻抗建模和扫频法验证的理论与实践技能。 其他说明:本文不仅提供理论知识,还附带了详细的代码实现和注释,便于读者快速上手并在实际项目中应用。此外,文中提到的一些实用技巧和注意事项也有助于提高实验效率和准确性。

    c语言打字母游戏源码.zip

    c语言打字母游戏源码.zip

    基于SOGI+DQ结构的PLL锁相环在STM32G431上的实现及其MATLAB仿真

    内容概要:本文详细介绍了基于SOGI(二阶广义积分器)和DQ变换的数字锁相环(PLL)在STM32G431芯片上的实现过程,并通过MATLAB进行了仿真验证。主要内容涵盖SOGI初始化、ADC采样配置、中断服务程序设计、DQ变换以及PLL频率跟踪等关键技术环节。文中特别强调了定点运算的应用,以提高运算效率和稳定性。同时,通过MATLAB仿真展示了系统的频率跟踪性能,在40Hz-65Hz范围内能够稳定跟踪电网频率变化,误差控制在±0.2Hz以内。此外,文章还讨论了移植性和硬件适配问题,提供了详细的代码片段和调试经验。 适合人群:从事电力电子、嵌入式系统开发的技术人员,尤其是对锁相环(PLL)和SOGI+DQ结构感兴趣的工程师。 使用场景及目标:适用于需要精确频率跟踪和相位同步的应用场合,如光伏逆变器并网、电机控制系统等。目标是帮助开发者理解和实现高效的PLL算法,确保系统在复杂电网环境下的稳定运行。 其他说明:文章不仅提供了理论分析和技术实现,还包括了大量的实践经验分享,如定点运算优化、硬件适配技巧等。对于希望深入理解PLL工作原理和实际应用的读者来说,是一份非常有价值的参考资料。

    【科学计算软件】MATLAB下载安装教程:涵盖Windows与macOS系统详细步骤及验证方法

    内容概要:本文档详细介绍了 MATLAB 在 Windows 和 macOS 系统上的下载与安装步骤。首先简述了 MATLAB 的应用领域,包括科学计算、数据分析和工程仿真。接着分别针对 Windows 和 macOS 用户提供了详细的安装指南,涵盖从访问官网、下载安装程序、选择许可证类型、指定安装路径、选择工具箱到最后的激活步骤。最后,通过输入特定命令验证 MATLAB 是否安装成功,确保用户能够顺利开始使用 MATLAB 进行相关工作。; 适合人群:对科学计算、数据分析和工程仿真有需求的科研人员、工程师以及学生等。; 使用场景及目标:①科研人员和工程师在工作中进行复杂的数据处理和建模;②学生学习数学、物理等相关课程时进行实验和模拟。; 阅读建议:本教程操作性强,建议读者按照步骤逐一操作,确保每一步都正确无误。遇到问题可随时查阅官方帮助文档或社区论坛,以便顺利完成 MATLAB 的安装和激活。

    【Linux详解】常用命令与系统配置:虚拟机搭建、文件管理及网络配置详解

    内容概要:本文详细介绍了Linux操作系统的概念、特点及其常见命令,旨在帮助用户掌握Linux的基础知识和操作技能。文章首先概述了Linux的操作系统特性,如免费、稳定、高效,以及其广泛的应用领域,包括服务器和个人设备。接着介绍了Linux的安装与配置,包括虚拟机的创建、分区设置、网络配置等。随后,重点讲解了Linux命令行的基本命令,涵盖文件和目录管理、用户和权限管理、进程和服务管理等方面。此外,还涉及了远程登录、文件传输、文本编辑器(如vi/vim)、定时任务、磁盘管理、网络配置、服务管理和包管理工具(如rpm/yum)。最后简要介绍了Shell编程的基础知识,包括变量、条件判断和脚本编写。 适合人群:适合初学者和有一定经验的Linux用户,特别是希望深入了解Linux系统管理和操作的IT从业者。 使用场景及目标:①帮助用户熟悉Linux操作系统的特性和应用场景;②掌握Linux系统的基本命令和操作技巧;③学会配置和管理Linux服务器,包括文件系统、用户权限、网络设置和服务管理;④能够编写简单的Shell脚本来自动化日常任务。 阅读建议:由于本文内容丰富且涉及面广,建议读者在学习过程中结合实际操作进行练习,特别是在命令行操作、文件管理、用户权限设置和Shell编程方面。对于复杂命令和概念,可以通过查阅官方文档或在线资源进一步加深理解。

    现代控制理论中倒立摆系统的MATLAB仿真及状态观测器与状态反馈控制设计

    内容概要:本文详细介绍了基于MATLAB的倒立摆系统状态观测器和状态反馈控制的设计与仿真。首先建立了倒立摆系统的状态空间模型,并验证了系统的能控性。然后利用LQR方法设计了状态反馈控制器,确保系统稳定并优化控制效果。接着设计了状态观测器,用于估计无法直接测量的状态变量。文中还讨论了观测器和控制器之间的协调设计,以及仿真过程中的一些注意事项和技术细节。最终通过Simulink进行了详细的仿真测试,展示了状态估计误差的快速收敛和系统的良好动态性能。 适合人群:从事控制系统设计的研究人员、工程师以及相关专业的高年级本科生和研究生。 使用场景及目标:适用于需要理解和掌握现代控制理论中状态观测器和状态反馈控制设计的实际应用场合,尤其是涉及复杂多变量系统的控制问题。目标是帮助读者深入理解这两者的协同工作原理及其在实际工程项目中的应用。 其他说明:文中提供了大量MATLAB代码片段,便于读者动手实践。同时强调了在实际工程应用中需要注意的问题,如参数选择、数值计算稳定性等。此外,还探讨了一些高级话题,如鲁棒性和非线性观测器的应用前景。

    电气设备故障仿真:变压器故障仿真.zip

    电子仿真教程,从基础到精通,每个压缩包15篇教程,每篇教程5000字以上。

Global site tag (gtag.js) - Google Analytics