易截截图软件、单文件、免安装、纯绿色、仅160KB

Java Programming 【replace tool】

常常需要递归的替换文件内容,如最近我想写了个jEdit插件,jEdit提供了一个插件模板,我只要全部替换一下就成了我自己的工程。在linux下,这好办,shell来搞定,但在Windows下或者不熟悉shell就得想点其他办法来办了,EditPlus可以,UE也可以,不过不太方便的是文件名不好替换,以前给自己写过一个小工具来成批改MP3的名字,后来发现用处蛮大,今天又有新要求了,我就写了MiniTool来完成这一MiniCase。没写UI,因为我自己的系统是RHEL5,喜欢命令行来操作。
Here is the running img by Hypersnap 5.
Here is the code. Just there are two Java files.
package com.jonsenelizee.replace;
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.Stack;
public class FormattingPrintWriter extends PrintWriter
{
private static final String NEWLINE = System.getProperty("line.separator", "\r\n");
// Standard tab settings
private static final int[] STD_TABS = { 9, 17, 25, 33, 41, 49, 57, 65, 73, 81 };
private boolean _autoFlush;
private int[] _tabs = STD_TABS;
@SuppressWarnings("unchecked")
private Stack _stack = new Stack();
private int _indent;
private int _pos;
/**
* Returns a string consisting of the specified number of spaces.
*
* @return The requested whitespace string.
*/
private static String spaces(int n)
{
char[] ca = new char[n];
for (int i = 0; i < n; i++)
ca[i] = ' ';
return new String(ca, 0, ca.length);
}
/**
* Constructs a new FormattingPrintWriter, without automatic line
* flushing.
*
* @param out
* A character-output stream.
*/
public FormattingPrintWriter(Writer out)
{
super(out);
}
/**
* Constructs a new FormattingPrintWriter.
*
* @param out
* A character-output stream.
* @param autoFlush
* If <code>true</code>, the println() methods will flush
* the output buffer.
*/
public Formattin


相关文档:

Java中集合容器类List和Set的用法

List的用法
List包括List接口以及List接口的所有实现类。因为List接口实现了Collection接口,所以List接口拥有Collection接口提供的所有常用方法,又因为List是列表类型,所以List接口还提供了一些适合于自身的常用方法,如表1所示。
表1  List接口定义的常用方法及功能
从表1可以看出,List接口提供的适合于自身的 ......

java:手写二叉树BinaryTree添加和查询方法

package arrays.myArray;
public class BinaryTree {
 private Node root;
 // 添加数据
 public void add(int data) {
  // 递归调用
  if (null == root)
   root = new Node(data, null, null);
  else
   addTree(root, data);
......

java:递归汉罗塔游戏最少的走法

package game;
public class HanTaGame {
 public static void main(String[] args) {
  fun('1', '2', '3', 2);
 }
 // 汉塔游戏解决方案
 public static void fun(char src, char idle, char dest, int n) {
  if (1 == n) {
   System.out.println(src ......

利用 Java 平台的特性建造一个令人瞩目的系统

   在过去的几年中,Java 平台技术取得了一些惊人进展。但这项技术在某些方面的广泛应用和它最初的
设计目标完全不同。Java 平台技术最初是希望通过客户端运行 Applet 和 application,来给网页增加交互性。而现在该技术最常见的
用途却是基于服务器的 J2EE 系统。为了让&n ......

Java 日志

19.1.1. Spring对log4j的几个增强
注意
个人建议都不要使用。
定时刷新log4j.properties,无须重启服务器更新log4j设置。虽然这是个J2EE Best
Practice,但在Spring的JavaDoc里注明了不推荐用于生产环境,因为服务器重启的时候,那条watch thread不会关闭。

log4j.properties文件放在WEB-INF/log4j.properti ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号