在Java中如何获得一个数组的首地址!!!在线等!急!!!!

Explorer22 2003-08-19 11:37:49
在Java中如何获得一个数组的首地址!!!在线等!急!!!!
...全文
648 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
Explorer22 2003-08-22
  • 打赏
  • 举报
回复
各位帮忙看一下:
第一个页面的代码:upload1.jsp

<%@ page contentType="text/html; charset=gb2312"
import="java.util.Date ,java.io.*,java.lang.*,java.text.SimpleDateFormat"%>
<HTML>
<BODY BGCOLOR="white">

<H1 align="center">图片、电影、音乐、新闻上传</H1>
<HR>

<FORM METHOD="POST" ACTION="/programe/uploadFile/upload.jsp" ENCTYPE="multipart/form-data">
<select name="Type" size="1" > //*****这是要传送的值“Type"********
<%

String path="";

path = request.getRealPath("./");

File d = new File(path);
//建立代表目前目录位置的File件, 并由d件变数引用

File list[] = d.listFiles();
//取得代表目录中所有文件的File件阵列
int j=list.length-3;
int i =0;
while(j>0)
{

%>
<option value="<%=list[i]%>"><%=list[i]%></option>
<%
i++;
j--;
}
%>
</select>
<select name="Year" size="1">
<%
Date today = new Date();
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
String sToday = format.format(today);
int lToday = Integer.parseInt(sToday);
int w = lToday%10000;
int ww=(lToday-w)/10000;

%>
<option value="<%=String.valueOf(ww)%>"><%=String.valueOf( ww)%></option>
</select>
<select name="Month" size="1">
<%
for(int month=1;month<=12;month++)
{
%>
<option value="<%=String.valueOf(month)%>"><%=String.valueOf( month)%></option>
<%
}
%>
</select>
<select name="Day" size="1">
<%
for(int day=1;day<=31;day++)
{
%>
<option value="<%=String.valueOf(day)%>"><%=String.valueOf(day)%></option>
<%
}
%>
</select>

<br>
<INPUT TYPE="FILE" NAME="FILE1" SIZE="50"><BR>
<INPUT TYPE="FILE" NAME="FILE2" SIZE="50"><BR>
<INPUT TYPE="FILE" NAME="FILE3" SIZE="50"><BR>
<INPUT TYPE="FILE" NAME="FILE4" SIZE="50"><BR>
<INPUT TYPE="SUBMIT" VALUE="Upload">
</FORM>

</BODY>
</HTML>

第二个页面的代码:upload.jsp
<%@ page contentType="text/html; charset=gb2312" language="java"
import="com.jspsmart.upload.*,java.io.File,java.lang.*,java.util.Date,java.text.SimpleDateFormat"%>
<jsp:useBean id="mySmartUpload" scope="page" class="com.jspsmart.upload.SmartUpload" />


<HTML>
<head>
<title>Images,Movies,Music,News UpLoaded</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

</head>

<BODY BGCOLOR="white">

<H1 align="center">Images,Movies,Music,News UpLoaded</H1>
<HR>

<%

String type = request.getParameter("Type"); //********这是接收这个传送的值******
//String year = request.getParameter("Year");
//String month =request.getParameter("Month");
//String day = request.getParameter("Day");
out.println(type);

String path="";

path = request.getRealPath("./");

File d = new File(path);
//建立代表目前目录位置的File件, 并由d件变数引用

File list[] = d.listFiles();
//取得代表目录中所有文件的File件阵列
%>

<%
// Variables
int count=0;

// Initialization
mySmartUpload.initialize(pageContext);

// Only allow txt or htm files
mySmartUpload.setAllowedFilesList(" gif,jpg,swf,txt");

// DeniedFilesList can also be used :
// mySmartUpload.setDeniedFilesList("exe,bat,jsp");

// Deny physical path
// mySmartUpload.setDenyPhysicalPath(true);

// Only allow files smaller than 2000000 bytes
mySmartUpload.setMaxFileSize(2000000);

// Deny upload if the total fila size is greater than 800000 bytes
mySmartUpload.setTotalMaxFileSize(800000);

// Upload
mySmartUpload.upload();

//look for file path ,if there is nothing ,create file path
File myFilePath = new File(type);
if(!myFilePath.exists())
myFilePath.mkdir();

String nextFilePath="";
nextFilePath = request.getRealPath("myFilePath/");


Date today = new Date();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
String sToday = format.format(today);



String fileName =sToday;
File myFile = new File(nextFilePath+"/"+fileName);
if(!myFile.exists())
myFile.mkdir();
String filePath = nextFilePath+"/"+fileName;

// Save the files with their original names in a virtual path of the web server
try {

count = mySmartUpload.save(filePath, mySmartUpload.SAVE_VIRTUAL);

} catch (Exception e){

out.println("<b>Wrong selection : </b>" + e.toString());

}

// Display the number of files uploaded
out.println(count + " file(s) uploaded.");

%>


<table width="85%" border="0" cellpadding="3" cellspacing="0">
<tr>
<td colspan="8">在<Font color = red><%= path%></Font>目录下的文件 一共有 <font color="#FF0000"><%=list.length%></font>
个文件或目录  <a href="javascript:history.back(1)">返回</a>   <a href="javascript:location.reload()">刷新</a> </td>
</tr>
</table>
<hr>

<table width="1000" height="150"border="0" align="center" cellpadding="3" cellspacing="0">
<%
for(int i=0; i <list.length/5; i++)
{
%>
<tr >
<%
for(int j=0;j<5;j++)
{
File f = new File(path,list[i*5+j].getName());
String file="";

file=list[i*5+j].getName();

//out.print(file.toString());
%>
<td align="center" width="120" height="150">
<a href="<%=file%>" target="_self"><img src="<%=file%>" width="120" height="150" name="<%=file.toString()%>" title="<%=file.toString()%>" ></a>
<a href="<%=file%>" target="_parent"><%=file%></a>
</td>
<%
}
%>
</tr>
<%
}
%>
</table>
<BR>
<a href="javascript:history.back(1)">Back</a>
</BODY>
</HTML>
大家帮忙看看为什么传过来的值接收后为空????在线等!!!!急啊!!!!!!!!!!!!


playboyxp 2003-08-21
  • 打赏
  • 举报
回复
java中没有指针,只有引用
Explorer22 2003-08-21
  • 打赏
  • 举报
回复
在问大家一个问题!!!
500 Servlet Exception
java.lang.NullPointerException
at java.io.File.<init>(File.java:180)
at _programe._uploadfile._upload__jsp._jspService (/programe/uploadFile/upload.jsp:47)
at com.caucho.jsp.JavaPage.service(JavaPage.java:75)
这样的异常怎么解决???由什么引起的,应该怎么着手解决???
我用的是resin,请各位帮忙了!!!!
limd 2003-08-20
  • 打赏
  • 举报
回复
java没有地址的概念,只有数组引用,不过我想数组引用变量中就是数组中的地址了。
Explorer22 2003-08-19
  • 打赏
  • 举报
回复
http://www.csdn.net/develop/Read_Article.asp?Id=16432
请上面的两位:javahui(阶级斗争要年年讲,月月讲,天天讲。) ,star821116(业精于勤荒于嬉,行成于思毁于随) 帮忙看一下这个帖,“m_currentIndex”怎么的到当前字节数组的指针位置???
帮忙啦!!!!
star821116 2003-08-19
  • 打赏
  • 举报
回复
请问要数组的首地址干嘛啊?Java中没这个东东
javahui 2003-08-19
  • 打赏
  • 举报
回复
JAVA里没有地址的概念。
cshchina 2003-08-19
  • 打赏
  • 举报
回复
Java中是没有地址的概念,但好像是只能得到数组引用的地址
刚才试图得到数组的首地址,未果
shine333 2003-08-19
  • 打赏
  • 举报
回复
大哥,只要你英文稍微好一点,就应该知道currentIndex的意思是“当前下标”,而不是什么指针(pointer)
realfishhook 2003-08-19
  • 打赏
  • 举报
回复
java里面没有地址指针……
至于你说的那篇文章里面的m_currentIndex,我看就是一个整数(用于指明位置),初始化的位置一般应当是0。

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧