日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

java添加文字水印插件_java之io添加文字水印

發布時間:2024/4/17 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java添加文字水印插件_java之io添加文字水印 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

實現統計個人某個目錄下的java 文件個數,總代碼行數。

package j09;

import java.io.BufferedReader;

import java.io.File;

import java.io.FileReader;

import java.io.IOException;

public class Tongh {

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

String str = "E:/java/";

tongji(str);

System.out.printf("java文件%d共%d行代碼",a,d);

}

public static void tongji(String str) {

try {

tongji(new File(str));

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

static int a = 0, s = 0, d = 0;

public static void tongji(File file) throws IOException {

if (file.isDirectory()) {

File[] ile = file.listFiles();

for (File il : ile) {

tongji(il);

}

} else {

String name = file.getName();String kuo="";

if(name.lastIndexOf(".")==-1) {}else {

kuo =name.substring(name.lastIndexOf("."));}

if (kuo. contains(".java")) {

++a;

FileReader read = new FileReader(file);

BufferedReader fil = new BufferedReader(read);

s=0;

while (fil.ready()) {

fil.readLine();

++s;

}

d += s;

System.out.println(file.getName()+s+"行");

}

}

}

}

自動加水印

package j09;

import java.awt.Color;

import java.awt.Font;

import java.awt.Graphics;

import java.awt.image.BufferedImage;

import java.io.File;

import java.io.IOException;

import javax.imageio.ImageIO;

public class Tu {

public static void main(String[] args) {

try {

shui();

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

static void shui() throws IOException {

String str="C:\\Users\\Administrator\\Pictures\\error.png";

File file=new File(str);

shui(file);

}

public static void shui(File file) throws IOException {

String dst=file.getPath();

BufferedImage s=ImageIO.read(file);

int width =s.getWidth();

int height= s.getHeight();

BufferedImage i=new BufferedImage(width,height, BufferedImage.TYPE_INT_RGB);

Graphics g=i.getGraphics();

g.drawImage(s, 0, 0, width,height,null);

g.setColor(new Color(0,0,122,50));

g.fillRect(0, 0, width, height);

g.setColor(new Color(255,32,122,120));

g.setFont(new Font("黑體",Font.BOLD,40));

int x=width-200;

int y=height-35;

g.drawString("你好哈", x, y);

g.dispose();

ImageIO.write(i, "jpg", new File(dst));

}

}

總結

以上是生活随笔為你收集整理的java添加文字水印插件_java之io添加文字水印的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。