「Java」の編集履歴(バックアップ)一覧に戻る

Java - (2007/10/24 (水) 22:10:44) の編集履歴(バックアップ)


  • 実行中のメソッド名を取得する。
new Throwable().getStackTrace()[0].getMethodName();

javascript:document.cookie;

  • プレースホルダ
String year = yyyy.format(selectedDate);
String month = MM.format(selectedDate);
String date = dd.format(selectedDate);
Object[] dateArgs = { year, month, date };
MessageFormat form = new MessageFormat("{0}年{1}月{2}日");

  • e.printStackTrace?()の文字列を取得する
StringWriter stringWriter = new StringWriter();
ex.printStackTrace(new PrintWriter(stringWriter));
String message = stringWriter.getBuffer().toString();

  • ソースをShift_JISで書いて、EUC-JPで出力するってこと
<%@ page contentType=text/html; charset=EUC-JP" pageEncoding="Shift_JIS" %>

Javaから、WEBブラウザを起動(Windowsのみ)

Runtime.getRuntime().exec( new String[] {
"rundll32.exe",
"url.dll,FileProtocolHandler",
"http://jp.sun.com/" 
});

  • WEBアプリケーションのルートを取得してパスを生成する
String root_path = this.getServletContext().getRealPath("/");
String file_path = root_path + "hoge.dat"


  • Set-Cookie: UserName=lightbox
Cookie UserName = new Cookie( "UserName", "lightbox" );
response.addCookie( UserName );
記事メニュー
目安箱バナー