如何获取Windows系统的最新聚焦高清壁纸?

2026-04-15 08:5412阅读0评论SEO资讯
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计303个文字,预计阅读时间需要2分钟。

如何获取Windows系统的最新聚焦高清壁纸?

javaWinSpotlight.javaimport java.io.*;import javax.imageio.ImageIO;import java.awt.image.BufferedImage;

如何获取Windows系统的最新聚焦高清壁纸?

public class WinSpotlight { public static void main(String[] args) throws IOException { copy(new File(System.getProperties().getProperty(user.home))); }

private static void copy(File source) throws IOException { File dest=new File(source.getAbsolutePath() + /WinSpotlight.png); BufferedImage image=ImageIO.read(source); ImageIO.write(image, png, dest); }}

WinSpotlight.java

import java.io.*; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; public class WinSpotlight { public static void main(String[] args) throws IOException { copy(new File(System.getProperties().getProperty("user.home")+"\\AppData\\Local\\Packages\\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\\LocalState\\Assets")); //renameToJpg(new File(".\\Assets")); } /*public static void renameToJpg(File file){ if(!file.exists()){ return; } File[] files = file.listFiles(); for(File f : files){ String fileName = f.getName(); if(fileName.equals("path.txt")||fileName.equals("RenameFile.class")){ continue; } int set = fileName.length(); if(fileName.lastIndexOf(".")>0){ set = fileName.lastIndexOf("."); } String name = fileName.substring(0, set); File newname = new File(file,name+".jpg"); f.renameTo(newname); } }*/ public static void copy(File resFile) throws IOException { if (!resFile.exists()) return; File horizontal = new File(".\\WinSpotlight\\Horizontal"); File vertical = new File(".\\WinSpotlight\\Vertical"); if(!horizontal.exists()) { horizontal.mkdirs(); } if(!vertical.exists()) { vertical.mkdirs(); } if (resFile.isFile()) { if(resFile.length()<61440L){ return; } File objFile = null; if(getPictureWidth(resFile)==1920){ objFile = new File(".\\WinSpotlight\\Horizontal\\" + resFile.getName() + ".jpg"); } else if(getPictureWidth(resFile)==1080) { objFile = new File(".\\WinSpotlight\\Vertical\\" + resFile.getName() + ".jpg"); } InputStream ins = new FileInputStream(resFile); FileOutputStream outs = new FileOutputStream(objFile); byte[] buffer = new byte[1024 * 512]; int length; while ((length = ins.read(buffer)) != -1) { outs.write(buffer, 0, length); } ins.close(); outs.flush(); outs.close(); } else { for (File sf : resFile.listFiles()) { copy(sf); } } } public static int getPictureWidth(File picture) throws IOException{ BufferedImage sourceImg =ImageIO.read(new FileInputStream(picture)); return sourceImg.getWidth(); } }

本文共计303个文字,预计阅读时间需要2分钟。

如何获取Windows系统的最新聚焦高清壁纸?

javaWinSpotlight.javaimport java.io.*;import javax.imageio.ImageIO;import java.awt.image.BufferedImage;

如何获取Windows系统的最新聚焦高清壁纸?

public class WinSpotlight { public static void main(String[] args) throws IOException { copy(new File(System.getProperties().getProperty(user.home))); }

private static void copy(File source) throws IOException { File dest=new File(source.getAbsolutePath() + /WinSpotlight.png); BufferedImage image=ImageIO.read(source); ImageIO.write(image, png, dest); }}

WinSpotlight.java

import java.io.*; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; public class WinSpotlight { public static void main(String[] args) throws IOException { copy(new File(System.getProperties().getProperty("user.home")+"\\AppData\\Local\\Packages\\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\\LocalState\\Assets")); //renameToJpg(new File(".\\Assets")); } /*public static void renameToJpg(File file){ if(!file.exists()){ return; } File[] files = file.listFiles(); for(File f : files){ String fileName = f.getName(); if(fileName.equals("path.txt")||fileName.equals("RenameFile.class")){ continue; } int set = fileName.length(); if(fileName.lastIndexOf(".")>0){ set = fileName.lastIndexOf("."); } String name = fileName.substring(0, set); File newname = new File(file,name+".jpg"); f.renameTo(newname); } }*/ public static void copy(File resFile) throws IOException { if (!resFile.exists()) return; File horizontal = new File(".\\WinSpotlight\\Horizontal"); File vertical = new File(".\\WinSpotlight\\Vertical"); if(!horizontal.exists()) { horizontal.mkdirs(); } if(!vertical.exists()) { vertical.mkdirs(); } if (resFile.isFile()) { if(resFile.length()<61440L){ return; } File objFile = null; if(getPictureWidth(resFile)==1920){ objFile = new File(".\\WinSpotlight\\Horizontal\\" + resFile.getName() + ".jpg"); } else if(getPictureWidth(resFile)==1080) { objFile = new File(".\\WinSpotlight\\Vertical\\" + resFile.getName() + ".jpg"); } InputStream ins = new FileInputStream(resFile); FileOutputStream outs = new FileOutputStream(objFile); byte[] buffer = new byte[1024 * 512]; int length; while ((length = ins.read(buffer)) != -1) { outs.write(buffer, 0, length); } ins.close(); outs.flush(); outs.close(); } else { for (File sf : resFile.listFiles()) { copy(sf); } } } public static int getPictureWidth(File picture) throws IOException{ BufferedImage sourceImg =ImageIO.read(new FileInputStream(picture)); return sourceImg.getWidth(); } }