Java最新Demo:第二章:Java实现随机图像生成(人像,汽车,房屋等等,还没搞懂JVM

分享

首先分享一份学习大纲,内容较多,涵盖了互联网行业所有的流行以及核心技术,以截图形式分享:

(亿级流量性能调优实战+一线大厂分布式实战+架构师筑基必备技能+设计思想开源框架解读+性能直线提升架构技术+高效存储让项目性能起飞+分布式扩展到微服务架构…实在是太多了)

其次分享一些技术知识,以截图形式分享一部分:

Tomcat架构解析:

算法训练+高分宝典:

Spring Cloud+Docker微服务实战:

最后分享一波面试资料:

切莫死记硬背,小心面试官直接让你出门右拐

1000道互联网Java面试题:

Java高级架构面试知识整理:

本文已被CODING开源项目:【一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频+实战项目源码】收录

需要这份系统化的资料的朋友,可以点击这里获取

*/

@Slf4j

public class SVGConverterUtils {

public static void main(String[] args) throws Exception {

String svgpath = “E:\svgfile\c.svg”;

File svgFile = new File(svgpath);

String name = svgFile.getName();

name = name.substring(0, name.lastIndexOf(“.”));

// converter.svg2PDF(new File(svgpath), new File(“E:/” + name + “_SVG文件转PDF.pdf”));

// converter.svg2PNG(new File(svgpath), new File(“E:/” + name + “_SVG文件转PNG.png”));

svg2JPEG(new File(svgpath), new File(“E:/” + name + “_SVG文件转JPG.jpg”));

String svgCode = svg2String(new File(svgpath));

// converter.svg2PDF(svgCode, “D:/” + name + “_SVG代码转PDF.pdf”);

// converter.svg2PNG(svgCode, “D:/” + name + “_SVG代码转PNG.png”);

// converter.svg2JPEG(svgCode, “D:/” + name + “_SVG代码转JPG.jpg”);

// converter.svg2PDF(svgCode, new FileOutputStream(new File(“E:/svgfile/” + name + “_SVG代码转输出流.pdf”)));

// converter.svg2PNG(svgCode, new FileOutputStream(new File(“E:/svgfile/” + name + “_SVG代码转输出流.png”)));

// converter.svg2JPEG(svgCode, new FileOutputStream(new File(“E:/svgfile/” + name + “_SVG代码转输出流.jpg”)));

// converter.svg2EPS(svgCode, new FileOutputStream(new File(“E:/svgfile/” + name + “_SVG代码转输出流.eps”)));

// converter.svg2PS(svgCode, new FileOutputStream(new File(“E:/svgfile/” + name + “_SVG代码转输出流.ps”)));

svgtoeps(svgCode, new FileOutputStream(new File(“E:/svgfile/” + name + “_SVG代码转输出流.eps”)));

}

public static File svgFileChangeJpg(File svgFile, String jpgPath){

log.info(“========svgFileChangeJpg.jpgPath:” + jpgPath);

try {

File file = new File(jpgPath);

if (file.exists()) {

file.delete();

}else {

file.getParentFile().mkdir();

file.createNewFile();

}

log.info(“========svgFileChangeJpg.jpgFile:” + file);

log.info(“========svgFileChangeJpg.svgFile:” + svgFile);

svg2JPEG(svgFile, file);

return file;

} catch (Exception e) {

log.error(e.getMessage());

}

return null;

}

public static void svgtoeps(String svgCode, OutputStream os){

EPSTranscoder epsTranscoder = new EPSTranscoder();

try {

svgCode = svgCode.replaceAll(“:rect”, “rect”);

TranscoderInput input = new TranscoderInput(new ByteArrayInputStream(svgCode.getBytes()));

TranscoderOutput output = new TranscoderOutput(os);

epsTranscoder.transcode(input, output);

os.flush();

os.close();

} catch (Exception e) {

}

}

/**

  • SVG转PNG

  • @param svgCode SVG代码

  • @param outpath 输出路径

  • @throws TranscoderException

  • @throws IOException

*/

public void svg2PNG(String svgCode, String outpath) throws TranscoderException, IOException {

Transcoder transcoder = new PNGTranscoder();

svgConverte(svgCode, outpath, transcoder);

}

/**

  • SVG转PNG

  • @param svgCode SVG代码

  • @param out 输出流

  • @throws TranscoderException

  • @throws IOException

*/

public void svg2PNG(String svgCode, OutputStream out) throws TranscoderException, IOException {

Transcoder transcoder = new PNGTranscoder();

svgConverte(svgCode, out, transcoder);

}

/**

  • SVG转PNG

  • @param svgFile SVG文件

  • @param outFile 输出文件

  • @throws TranscoderException

  • @throws IOException

*/

public void svg2PNG(File svgFile, File outFile) throws TranscoderException, IOException {

Transcoder transcoder = new PNGTranscoder();

svgConverte(svgFile, outFile, transcoder);

}

/**

  • SVG转JPG

  • @param svgCode SVG代码

  • @param outpath 输出路径

  • @throws TranscoderException

  • @throws IOException

*/

public void svg2JPEG(String svgCode, String outpath) throws TranscoderException, IOException {

Transcoder transcoder = new JPEGTranscoder();

//为防止ERROR: The JPEG quality has not been specified. Use the default one: no compression 错误,需如下配置

transcoder.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, 0.99f);

svgConverte(svgCode, outpath, transcoder);

}

/**

  • SVG转JPG

  • @param svgCode SVG代码

  • @param out 输出流

  • @throws TranscoderException

  • @throws IOException

*/

public void svg2JPEG(String svgCode, OutputStream out) throws TranscoderException, IOException {

Transcoder transcoder = new JPEGTranscoder();

//为防止ERROR: The JPEG quality has not been specified. Use the default one: no compression 错误,需如下配置

transcoder.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, 0.99f);

svgConverte(svgCode, out, transcoder);

}

/**

  • SVG转JPG

  • @param svgFile SVG文件

  • @param outFile 输出文件

  • @throws TranscoderException

  • @throws IOException

*/

public static void svg2JPEG(File svgFile, File outFile) throws TranscoderException, IOException {

Transcoder transcoder = new JPEGTranscoder();

//为防止ERROR: The JPEG quality has not been specified. Use the default one: no compression 错误,需如下配置

transcoder.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, 0.99f);

svgConverte(svgFile, outFile, transcoder);

}

/**

  • SVG转PDF

  • @param svgCode SVG代码

  • @param outpath 输出路径

  • @throws TranscoderException

  • @throws IOException

*/

public void svg2PDF(String svgCode, String outpath) throws TranscoderException, IOException {

Transcoder transcoder = new PDFTranscoder();

svgConverte(svgCode, outpath, transcoder);

}

/**

  • SVG转PS

  • @param svgCode

  • @param outpath

  • @throws TranscoderException

  • @throws IOException

*/

public void svg2PS(String svgCode, String outpath) throws TranscoderException, IOException {

Transcoder transcoder = new PSTranscoder();

svgConverte(svgCode, outpath, transcoder);

}

/**

  • SVG转PS

  • @param svgCode SVG代码

  • @param out 输出流

  • @throws TranscoderException

  • @throws IOException

*/

public void svg2PS(String svgCode, OutputStream out) throws TranscoderException, IOException {

Transcoder transcoder = new PSTranscoder();

svgConverte(svgCode, out, transcoder);

}

/**

  • SVG转EPS

  • @param svgCode SVG代码

  • @param out 输出流

  • @throws TranscoderException

  • @throws IOException

*/

public void svg2EPS(String svgCode, OutputStream out) throws TranscoderException, IOException {

Transcoder transcoder = new EPSTranscoder();

svgConverte(svgCode, out, transcoder);

}

/**

  • SVG转EPS

  • @param svgCode

  • @param outpath

  • @throws TranscoderException

  • @throws IOException

*/

public void svg2EPS(String svgCode, String outpath) throws TranscoderException, IOException {

Transcoder transcoder = new EPSTranscoder();

svgConverte(svgCode, outpath, transcoder);

}

/**

  • SVG转PDF

  • @param svgCode SVG代码

  • @param out 输出流

  • @throws TranscoderException

  • @throws IOException

*/

public void svg2PDF(String svgCode, OutputStream out) throws TranscoderException, IOException {

Transcoder transcoder = new PDFTranscoder();

svgConverte(svgCode, out, transcoder);

}

/**

  • SVG转PDF

  • @param svgFile SVG文件

  • @param outFile 输出文件

  • @throws TranscoderException

  • @throws IOException

*/

public void svg2PDF(File svgFile, File outFile) throws TranscoderException, IOException {

Transcoder transcoder = new PDFTranscoder();

svgConverte(svgFile, outFile, transcoder);

}

private void svgConverte(String svgCode, String outpath, Transcoder transcoder) throws IOException, TranscoderException {

svgConverte(svgCode, getOutputStream(outpath), transcoder);

}

private static void svgConverte(File svg, File outFile, Transcoder transcoder) throws IOException, TranscoderException {

svgConverte(svg2String(getInputStream(svg)), getOutputStream(outFile), transcoder);

}

private static void svgConverte(String svgCode, OutputStream out, Transcoder transcoder) throws IOException, TranscoderException {

svgCode = svgCode.replaceAll(“:rect”, “rect”);

TranscoderInput input = new TranscoderInput(new ByteArrayInputStream(svgCode.getBytes()));

TranscoderOutput output = new TranscoderOutput(out);

svgConverte(input, output, transcoder);

}

private static void svgConverte(TranscoderInput input, TranscoderOutput output, Transcoder transcoder) throws IOException, TranscoderException {

transcoder.transcode(input, output);

}

public static InputStream getInputStream(File file) throws IOException {

return new FileInputStream(file);

}

public InputStream getInputStream(String filepath) throws IOException {

File file = new File(filepath);

if (file.exists())

return getInputStream(file);

else

return null;

}

public static OutputStream getOutputStream(File outFile) throws IOException {

return new FileOutputStream(outFile);

}

public OutputStream getOutputStream(String outpath) throws IOException {

File file = new File(outpath);

if (!file.exists())

file.createNewFile();

return getOutputStream(file);

}

/**

  • 默认使用编码UTF-8 SVG文件输入流转String

  • @param svgFile

  • @return SVG代码

  • @throws IOException

*/

public static String svg2String(File svgFile) throws IOException {

InputStream in = getInputStream(svgFile);

return svg2String(in, “UTF-8”);

}

/**

  • SVG文件输入流转String

  • @param svgFile

  • @return SVG代码

  • @throws IOException

*/

public String svg2String(File svgFile, String charset) throws IOException {

InputStream in = getInputStream(svgFile);

return svg2String(in, charset);

}

/**

  • 默认使用编码UTF-8SVG输入流转String

  • @param in

  • @return SVG代码

*/

public static String svg2String(InputStream in) {

return svg2String(in, “UTF-8”);

}

/**

  • 指定字符集SVG输入流转String

  • @param in 输入流

  • @param charset 字符编码

总结

谈到面试,其实说白了就是刷题刷题刷题,天天作死的刷。。。。。

为了准备这个“金三银四”的春招,狂刷一个月的题,狂补超多的漏洞知识,像这次美团面试问的算法、数据库、Redis、设计模式等这些题目都是我刷到过的

并且我也将自己刷的题全部整理成了PDF或者Word文档(含详细答案解析)

我的美团offer凉凉了?开发工程师(Java岗)三面结束等通知...

66个Java面试知识点

架构专题(MySQL,Java,Redis,线程,并发,设计模式,Nginx,Linux,框架,微服务等)+大厂面试题详解(百度,阿里,腾讯,华为,迅雷,网易,中兴,北京中软等)

我的美团offer凉凉了?开发工程师(Java岗)三面结束等通知...

算法刷题(PDF)

我的美团offer凉凉了?开发工程师(Java岗)三面结束等通知...

本文已被CODING开源项目:【一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频+实战项目源码】收录

需要这份系统化的资料的朋友,可以点击这里获取

am in 输入流

  • @param charset 字符编码

总结

谈到面试,其实说白了就是刷题刷题刷题,天天作死的刷。。。。。

为了准备这个“金三银四”的春招,狂刷一个月的题,狂补超多的漏洞知识,像这次美团面试问的算法、数据库、Redis、设计模式等这些题目都是我刷到过的

并且我也将自己刷的题全部整理成了PDF或者Word文档(含详细答案解析)

[外链图片转存中…(img-b4tfzz8w-1715367474164)]

66个Java面试知识点

架构专题(MySQL,Java,Redis,线程,并发,设计模式,Nginx,Linux,框架,微服务等)+大厂面试题详解(百度,阿里,腾讯,华为,迅雷,网易,中兴,北京中软等)

[外链图片转存中…(img-cvMADGk3-1715367474165)]

算法刷题(PDF)

[外链图片转存中…(img-r068YQK5-1715367474165)]

本文已被CODING开源项目:【一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频+实战项目源码】收录

需要这份系统化的资料的朋友,可以点击这里获取

  • 20
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值