我使用下面的Java代码创建了一个CSV文件:
String csv = rs.getString("UPLOAD_FOLDER_PATH")+".csv";
CSVWriter writer = new CSVWriter(new FileWriter(csv));
String [] filevalues = new String[filevaluesarray.size()];
filevalues=filevaluesarray.toArray(filevalues);
writer.writeNext(filevalues);
writer.close();
Run Code Online (Sandbox Code Playgroud)
我收到了CSV文件,但该文件的内容包含不需要的双引号.
例如."ABC", "123", "KDNJ"
我不会从添加这些双引号的地方得到.
我使用java创建了zip文件,如下面的代码片段所示
import java.io.*;
import java.util.zip.*;
public class ZipCreateExample {
public static void main(String[] args) throws IOException {
System.out.print("Please enter file name to zip : ");
BufferedReader input = new BufferedReader
(new InputStreamReader(System.in));
String filesToZip = input.readLine();
File f = new File(filesToZip);
if(!f.exists()) {
System.out.println("File not found.");
System.exit(0);
}
System.out.print("Please enter zip file name : ");
String zipFileName = input.readLine();
if (!zipFileName.endsWith(".zip"))
zipFileName = zipFileName + ".zip";
byte[] buffer = new byte[18024];
try {
ZipOutputStream out = new ZipOutputStream
(new FileOutputStream(zipFileName)); …Run Code Online (Sandbox Code Playgroud) 我在windows xp上有tomcat 6服务器,我通过console启动tomcat,即使用startup.bat.
AFAIK catalina.bat文件用于Windows,所以我正在更改bat文件进行内存管理.我没有tomcat配置窗口.
现在我想增加它的堆大小所以我的问题是我应该扩展现有JAVA_OPTS的catalina.bat文件,即
set JAVA_OPTS=%JAVA_OPTS% -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file="%CATALINA_BASE%\conf\logging.properties" -Xms1024m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=128m
Run Code Online (Sandbox Code Playgroud)
或者我应该在catalina.bat文件中创建新的环境变量ie
set JAVA_OPTS=-Xms1024m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=128m
Run Code Online (Sandbox Code Playgroud)
这是正确的方法吗?
请指导.
我能够在Probe中看到当前的堆大小,但是无法查看现有的perm大小,因此perm大小的默认值是多少?
编辑:
以下参数有帮助吗?
-XX:+UseConcMarkSweepGC -XX:+CMSPermGenSweepingEnabled -XX:+CMSClassUnloadingEnabled
Run Code Online (Sandbox Code Playgroud) 我试过了
var d=new Date("2012-07-01 00:00:00.0");
alert(d.getMonth());
Run Code Online (Sandbox Code Playgroud)
但是得到NAN.
我想要上个月的月份July.
我正在尝试下面的代码,但得到错误
String x = "aaa XXX bbb";
String replace = "XXX";
String y = "xy$z";
String z=y.replaceAll("$", "\\$");
x = x.replaceFirst(replace, z);
System.out.println(x);
Run Code Online (Sandbox Code Playgroud)
错误
Exception in thread "main" java.lang.IllegalArgumentException: Illegal group reference
at java.util.regex.Matcher.appendReplacement(Unknown Source)
at java.util.regex.Matcher.replaceFirst(Unknown Source)
at java.lang.String.replaceFirst(Unknown Source)
at Test.main(Test.java:10)
Run Code Online (Sandbox Code Playgroud)
我希望结果为
aaa xy$z bbb
Run Code Online (Sandbox Code Playgroud) 我有桌子员工
我将列检索为 select emp_name,emp_add from employee
while(iResultSet1.next())
{
List expRptColWise = new ArrayList();
for(Integer i=1;i<=iResultSet1.getMetaData().getColumnCount();i++){
expRptColWise.add(iResultSet1.getString(i));
}
expRptRowWise.add(expRptColWise);
Run Code Online (Sandbox Code Playgroud)
有了上面的片段,我明白了
emp_name | emp_add |
A | add1 |
B | add2 |
Run Code Online (Sandbox Code Playgroud)
我想在结果集中添加序列号coloumn,以便得到结果
emp_name | emp_add |Sr_No|
A | add1 |1 |
B | add2 |2 |
Run Code Online (Sandbox Code Playgroud)
请指导我如何在结果集或集合对象中动态添加列,这里我使用了ArrayList.
我想做年份验证,它应该只是数字,它应该是4位数长,在1920年到当前年份之间我已经创建了java脚本函数,如下所示
function yearValidation(year) {
var text = /^[0-9]+$/;
if (year != 0) {
if ((year != "") && (!text.test(year))) {
alert("Please Enter Numeric Values Only");
return false;
}
if (year.length != 4) {
alert("Year is not proper. Please check");
return false;
}
var current_year=new Date().getFullYear();
if((year < 1920) || (year > current_year))
{
alert("Year should be in range 1920 to current year");
return false;
}
return true;
}
Run Code Online (Sandbox Code Playgroud)
并打电话给它 onkeypress="return yearValidation(this.value)"
但当我输入1时,它会让我警觉 Year should be in range 1920 to current …