forked from final-java-team12/frame_improve
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshortPants.java
54 lines (46 loc) · 1.29 KB
/
shortPants.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package team_12;
import java.io.IOException;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.util.List;
import java.util.ArrayList;
import java.nio.file.Path;
public class shortPants { //短袖
private List<Path> data = new ArrayList<Path>();
public void setShortPants(Path fileName) //設定資料
{
if(Files.isDirectory(fileName))
{
try{
DirectoryStream<Path> directoryStream = Files.newDirectoryStream(fileName);
for (Path p : directoryStream)
data.add(p);
}
catch (IOException E)
{
System.out.println("讀取錯誤");
}
}
else{
data.add(fileName);
}
printshortPants();
}
public void printshortPants() //印出資料
{
System.out.println("短褲資料:");
for(int i = 0; i < data.size(); i++) {
Path tmpData = data.get(i);
System.out.println(tmpData);
}
}
public String getPath(int i) //得到路徑
{
Path path = data.get(i);
return path.toString();
}
public int getSize()
{
return data.size();
} //得到大小
}