获取HttpSession缓存大小(Java代码)
来源:互联网 发布:win10安装软件 知乎 编辑:程序博客网 时间:2024/06/06 02:02
/**
* 获取HttpSession缓存大小
* @param session HttpSession
* @param filePath 输入文件
*/
public static void getSessionSize(HttpSession session, String filePath)
{
FileOutputStream fileOutputStream = null;
ObjectOutputStream objectOutputStream = null;
try
{
fileOutputStream = new FileOutputStream(filePath);
objectOutputStream = new ObjectOutputStream(fileOutputStream);
objectOutputStream.writeObject("session:");
Enumeration<String> names = session.getAttributeNames();
while (names.hasMoreElements())
{
objectOutputStream.writeObject(session.getAttribute(names.nextElement()));
}
objectOutputStream.flush();
}
catch (Exception e)
{
e.printStackTrace();
try
{
if (null != objectOutputStream)
{
objectOutputStream.close();
}
}
catch (IOException e1)
{
System.out.println(e1.toString());
}
try
{
if (null != fileOutputStream)
{
fileOutputStream.close();
}
}
catch (IOException e1)
{
System.out.println(e1.toString());
}
}
finally
{
if (null != objectOutputStream)
{
try
{
objectOutputStream.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
if (null != fileOutputStream)
{
try
{
fileOutputStream.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
}
* 获取HttpSession缓存大小
* @param session HttpSession
* @param filePath 输入文件
*/
public static void getSessionSize(HttpSession session, String filePath)
{
FileOutputStream fileOutputStream = null;
ObjectOutputStream objectOutputStream = null;
try
{
fileOutputStream = new FileOutputStream(filePath);
objectOutputStream = new ObjectOutputStream(fileOutputStream);
objectOutputStream.writeObject("session:");
Enumeration<String> names = session.getAttributeNames();
while (names.hasMoreElements())
{
objectOutputStream.writeObject(session.getAttribute(names.nextElement()));
}
objectOutputStream.flush();
}
catch (Exception e)
{
e.printStackTrace();
try
{
if (null != objectOutputStream)
{
objectOutputStream.close();
}
}
catch (IOException e1)
{
System.out.println(e1.toString());
}
try
{
if (null != fileOutputStream)
{
fileOutputStream.close();
}
}
catch (IOException e1)
{
System.out.println(e1.toString());
}
}
finally
{
if (null != objectOutputStream)
{
try
{
objectOutputStream.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
if (null != fileOutputStream)
{
try
{
fileOutputStream.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
}
0 0
- 获取HttpSession缓存大小(Java代码)
- java WebSocket 获取httpSession
- iOS获取缓存大小
- SDWebImage 获取缓存大小
- 获取缓存大小+清除缓存大小
- Java HttpSession
- Java-HttpSession
- iOS 获取应用程序缓存大小
- iOS 获取应用程序缓存大小
- 29.获取文件缓存大小
- 获取缓存大小和清除缓存功能
- 获取缓存大小和清除缓存功能
- iOS 获取缓存大小 清除缓存
- 获取缓存的大小 以及清理缓存
- Android ASimpleCache缓存框架 获取缓存大小
- SDWebImage获取缓存大小,清除缓存
- 获取缓存大小和清除缓存功能
- 获取缓存的大小和清除缓存
- QTableView自动调整列宽行高
- 一个简单的波形包络提取算法
- ios 禁止横屏
- HD 2045 递推 //不容易系列之(3)—— LELE的RPG难题
- 音乐播放器的Wii对于无极限乐趣
- 获取HttpSession缓存大小(Java代码)
- widget,MainWindow和Dialog的选择使用
- 金立的Gpad G2
- 【转】Vim入门基础
- 栈的C数组实现
- asp.net webconfig文件详解
- IOS研究之蒙特卡罗法求圆周率π(PI)(
- 在SDK Manager中下载不同版本的Android时很慢或者失败
- hdoj.2005 第几天? 20140721