This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package test; | |
import javax.ws.rs.GET; | |
import javax.ws.rs.Path; | |
import javax.ws.rs.QueryParam; | |
// http://localhost:8080/JerseySample/sample/hello?name=aaa&age=100 | |
@Path("/hello") | |
public class HelloResource { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected void doGet(HttpServletRequest request, | |
HttpServletResponse response) throws ServletException, IOException { | |
// logon user name | |
final String userName = request.getUserPrincipal().getName(); | |
PrintWriter out = response.getWriter(); | |
out.println(String.format("doGet(%s)", userName)); | |
out.flush(); | |
out.close(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package test; | |
import java.io.IOException; | |
import java.util.ArrayList; | |
import java.util.List; | |
import java.util.Set; | |
import javax.servlet.ServletException; | |
import javax.servlet.annotation.WebServlet; | |
import javax.servlet.http.HttpServlet; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PropertyUtil { | |
private static final String PROPERTY_FILE_TEST = "test.properties"; | |
public static void setTestPropertyValue(ServletContext context, String key, String value) { | |
setPropertyValue(context, PROPERTY_FILE_TEST, key, value); | |
} | |
public static String getTestPropertyValue(ServletContext context, String key) { | |
return getPropertyValue(context, PROPERTY_FILE_TEST, key); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void unzip(String zipFilePath, File dstDir) { | |
try { | |
final ZipFile zipFile = new ZipFile(zipFilePath); | |
Enumeration<? extends ZipEntry> enumZip = zipFile.entries(); | |
while (enumZip.hasMoreElements()) { | |
final ZipEntry zipEntry = enumZip.nextElement(); | |
// 出力先設定 | |
File dstFile = new File(dstDir, zipEntry.getName()); | |
if (dstFile.isDirectory()) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// クラスパスルートからの相対パスを指定 | |
private static final String relativePath = "/resources/aaa.txt"; | |
private String getRealResourcePath(String relativePath) { | |
return getClass().getClassLoader().getResource(relativePath).getPath(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// dir name(class pathをルートとする相対パス) | |
private static final String DIR_NAME = "json"; | |
private static final String FILE_NAME = "test.json"; | |
public static String createJsonText(Class<? extends HttpServlet> clazz) { | |
return createJsonText(clazz, DIR_NAME, FILE_NAME); | |
} | |
public static String createJsonText(Class<? extends HttpServlet> clazz, String dirName, String fileName) { | |
String dirPath = clazz.getClassLoader().getResource(dirName).getPath(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface JsonModel { | |
// model | |
} | |
public class JsonUtil { | |
@SuppressWarnings("unchecked") | |
public static <T> T fromJson(String jsonText, Class<? extends JsonModel> T) { | |
Gson gson = new Gson(); | |
return (T) gson.fromJson(jsonText, T); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package test.handler; | |
import android.app.Activity; | |
import android.os.Bundle; | |
import android.os.Handler; | |
import android.os.HandlerThread; | |
import android.view.View; | |
import android.view.View.OnClickListener; | |
public class MainActivity extends Activity { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package test.fragment.list; | |
import test.fragment.list.ImageFactory.Type; | |
import android.content.Context; | |
import android.graphics.Bitmap; | |
import android.graphics.Canvas; | |
import android.graphics.drawable.BitmapDrawable; | |
import android.util.AttributeSet; | |
import android.widget.ImageView; |
OlderNewer