文件名称:abc
介绍说明--下载内容均来自于网络,请自行研究使用
查看某个文件夹中的图片,显示在网页中。程序片:
package tom.jiafei
import java.io.*
class FileName implements FilenameFilter
{ public boolean accept(File dir,String name)
{ boolean boo=false
if(name.endsWith(".jpg")||name.endsWith(".JPG"))
boo=true
return boo
}
}
public class Play
{ int imageNumber=0,max
String pictureName[],playImage
public Play()
{ File dir=new File("D:/myjsp/image")
pictureName=dir.list(new FileName())
max=pictureName.length
}
public void setImageNumber(int n)
{ if(n<0)
n=max-1
if(n==max)
n=0
imageNumber=n
}
public int getImageNumber()
{ return imageNumber
}
public String getPlayImage()
{ playImage=new String("<image src=image/"+pictureName[imageNumber]+" "+
" width=900 height=800></image>")
return playImage
}
}-View the picture in a folder, displayed in Web pages. Applet: package tom.jiafei import java.io.* class FileName implements FilenameFilter {public boolean accept (File dir, String name) {boolean boo = false if (name.endsWith (" . Jpg" ) | | name . endsWith (" . JPG" )) boo = true return boo }} public class Play {int imageNumber = 0, max String pictureName [], playImage public Play () {File dir = new File (" D:/myjsp/image " ) pictureName = dir.list (new FileName ()) max = pictureName.length } public void setImageNumber (int n) {if (n < 0) n = max-1 if (n = = max) n = 0 imageNumber = n } public int getImageNumber () {return imageNumber } public String getPlayImage () {playImage = new String (" <image src=image/"+pictureName[imageNumber]+" "+
" width=900 height=800></image> " ) Return playImage }}
package tom.jiafei
import java.io.*
class FileName implements FilenameFilter
{ public boolean accept(File dir,String name)
{ boolean boo=false
if(name.endsWith(".jpg")||name.endsWith(".JPG"))
boo=true
return boo
}
}
public class Play
{ int imageNumber=0,max
String pictureName[],playImage
public Play()
{ File dir=new File("D:/myjsp/image")
pictureName=dir.list(new FileName())
max=pictureName.length
}
public void setImageNumber(int n)
{ if(n<0)
n=max-1
if(n==max)
n=0
imageNumber=n
}
public int getImageNumber()
{ return imageNumber
}
public String getPlayImage()
{ playImage=new String("<image src=image/"+pictureName[imageNumber]+" "+
" width=900 height=800></image>")
return playImage
}
}-View the picture in a folder, displayed in Web pages. Applet: package tom.jiafei import java.io.* class FileName implements FilenameFilter {public boolean accept (File dir, String name) {boolean boo = false if (name.endsWith (" . Jpg" ) | | name . endsWith (" . JPG" )) boo = true return boo }} public class Play {int imageNumber = 0, max String pictureName [], playImage public Play () {File dir = new File (" D:/myjsp/image " ) pictureName = dir.list (new FileName ()) max = pictureName.length } public void setImageNumber (int n) {if (n < 0) n = max-1 if (n = = max) n = 0 imageNumber = n } public int getImageNumber () {return imageNumber } public String getPlayImage () {playImage = new String (" <image src=image/"+pictureName[imageNumber]+" "+
" width=900 height=800></image> " ) Return playImage }}
(系统自动生成,下载前可以参看下载内容)
下载文件列表
浏览图片代码\showPic.jsp
............\WEB-INF\classes\Play.java
............\.......\.......\tom\jiafei\FileName.class
............\.......\.......\...\......\Play.class
............\.......\.......\...\jiafei
............\.......\.......\tom
............\.......\classes
............\WEB-INF
浏览图片代码