File: java.io.File

package info (click to toggle)
bock 0.20.2.1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,228 kB
  • ctags: 1,370
  • sloc: ansic: 7,367; java: 5,553; yacc: 963; lex: 392; makefile: 243; sh: 90; perl: 42
file content (176 lines) | stat: -rw-r--r-- 4,480 bytes parent folder | download | duplicates (3)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
// java.io.File
// An implementation of the Java Language Specification section 22.24
// Written by Charles Briscoe-Smith; refer to the file LEGAL for details.

package java.io;

public class File {

	public static final String separator =
		System.getProperty("file.separator");
	public static final char separatorChar = separator.charAt(0);
	public static final String pathSeparator =
		System.getProperty("path.separator");
	public static final char pathSeparatorChar = pathSeparator.charAt(0);

	private String pathname;

	public File(String path) throws NullPointerException
	{
		if (path==null) throw new NullPointerException();
		pathname=path;
	}

	public File(String dir, String name) throws NullPointerException
	{
		if (name==null) throw new NullPointerException();
		if (dir==null)
			pathname=name;
		else
			pathname=dir+separatorChar+name;
	}

	public File(File dir, String name) throws NullPointerException
	{
		this(dir.getPath(), name);
	}

	public String toString()
	{
		return pathname;
	}

	public boolean equals(Object o)
	{
		try {
			return ((File) o).getPath().equals(pathname);
		} catch (NullPointerException e) {
			return false;
		} catch (ClassCastException e) {
			return false;
		}
	}

	public int hashCode()
	{
		return pathname.hashCode() ^ 1234321;
	}

	public String getName()
	{
		return pathname.substring(pathname.lastIndexOf(separatorChar));
	}

	public String getPath()
	{
		return pathname;
	}

	public String getAbsolutePath()
	{
		throw new InternalError("getAbsolutePath() unimplemented.");
	}

	public String getParent()
	{
		throw new InternalError("getParent() unimplemented.");
	}

	public boolean isAbsolute()
	{
		return pathname.charAt(0)==separatorChar;
	}

	public boolean exists() throws SecurityException
	{
		SecurityManager sec=System.getSecurityManager();
		if (sec!=null) sec.checkRead(pathname);
		throw new InternalError("exists() unimplemented.");
	}

	public boolean canRead() throws SecurityException
	{
		SecurityManager sec=System.getSecurityManager();
		if (sec!=null) sec.checkRead(pathname);
		throw new InternalError("canRead() unimplemented.");
	}

	public boolean canWrite() throws SecurityException
	{
		SecurityManager sec=System.getSecurityManager();
		if (sec!=null) sec.checkWrite(pathname);
		throw new InternalError("canWrite() unimplemented.");
	}

	public boolean isFile() throws SecurityException
	{
		SecurityManager sec=System.getSecurityManager();
		if (sec!=null) sec.checkRead(pathname);
		throw new InternalError("isFile() unimplemented.");
	}

	public boolean isDirectory() throws SecurityException
	{
		SecurityManager sec=System.getSecurityManager();
		if (sec!=null) sec.checkRead(pathname);
		throw new InternalError("isDirectory() unimplemented.");
	}

	public long lastModified() throws SecurityException
	{
		SecurityManager sec=System.getSecurityManager();
		if (sec!=null) sec.checkRead(pathname);
		throw new InternalError("lastModified() unimplemented.");
	}

	public long length() throws SecurityException
	{
		SecurityManager sec=System.getSecurityManager();
		if (sec!=null) sec.checkRead(pathname);
		throw new InternalError("length() unimplemented.");
	}

	public boolean mkdir() throws SecurityException
	{
		SecurityManager sec=System.getSecurityManager();
		if (sec!=null) sec.checkWrite(pathname);
		throw new InternalError("mkdir() unimplemented.");
	}

	public boolean mkdirs() throws SecurityException
	{
		SecurityManager sec=System.getSecurityManager();
		if (sec!=null) sec.checkWrite(pathname);
		throw new InternalError("mkdirs() unimplemented.");
	}

	public String[] list() throws SecurityException
	{
		SecurityManager sec=System.getSecurityManager();
		if (sec!=null) sec.checkRead(pathname);
		throw new InternalError("list() unimplemented.");
	}

	public String[] list(FilenameFilter f) throws SecurityException
	{
		SecurityManager sec=System.getSecurityManager();
		if (sec!=null) sec.checkRead(pathname);
		throw new InternalError("list(FilenameFilter) unimplemented.");
	}

	public boolean renameTo(File dest) throws SecurityException
	{
		SecurityManager sec=System.getSecurityManager();
		if (sec!=null) sec.checkWrite(pathname);
		if (sec!=null) sec.checkWrite(dest.getPath());
		throw new InternalError("renameTo(File) unimplemented.");
	}

	public boolean delete() throws SecurityException
	{
		SecurityManager sec=System.getSecurityManager();
		if (sec!=null) sec.checkWrite(pathname);
		throw new InternalError("delete() unimplemented.");
	}

}