IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
IKVM.Java.Externs.java.io.FileOutputStream Class Reference

Static Public Member Functions

static void open0 (object this_, string path, bool append)
 Implements the native method 'open0'.
 
static void write (object self, int byte_, bool append)
 Implements the native method 'write'.
 
static void writeBytes (object self, byte[] bytes, int off, int len, bool append)
 Implements the native method 'writeBytes'.
 
static void close0 (object this_)
 Implements the native method 'close0'.
 

Detailed Description

Definition at line 14 of file FileOutputStream.cs.

Member Function Documentation

◆ close0()

static void IKVM.Java.Externs.java.io.FileOutputStream.close0 ( object this_)
static

Implements the native method 'close0'.

Parameters
this_

Definition at line 245 of file FileOutputStream.cs.

246 {
247#if FIRST_PASS
248 throw new NotImplementedException();
249#else
250 var fd = FileOutputStreamAccessor.GetFd(this_);
251 if (fd == null)
252 throw new global::java.io.IOException("The handle is invalid.");
253
254 if (FileDescriptorAccessor.GetStream(fd) is Stream stream)
255 {
256 try
257 {
258 stream.Close();
259 FileDescriptorAccessor.SetPtr(fd, -1);
260 }
261 catch
262 {
263 // ignore
264 }
265 }
266 else
267 {
268 __callerID ??= global::ikvm.@internal.CallerID.create(typeof(global::java.io.FileOutputStream).TypeHandle);
269 __jniPtr__close0 ??= Marshal.GetDelegateForFunctionPointer<__jniDelegate__close0>(JNIFrame.GetFuncPtr(__callerID, "java/io/FileOutputStream", nameof(close0), "()V"));
270 var jniFrm = new JNIFrame();
271 var jniEnv = jniFrm.Enter(__callerID);
272 try
273 {
274 __jniPtr__close0(jniEnv, jniFrm.MakeLocalRef(this_));
275 }
276 catch (Exception ex)
277 {
278 System.Console.WriteLine("*** exception in native code ***");
279 System.Console.WriteLine(ex);
280 throw;
281 }
282 finally
283 {
284 jniFrm.Leave();
285 }
286 }
287#endif
288 }
static void close0(object this_)
Implements the native method 'close0'.
static nint GetFuncPtr(object callerID, string clazz, string name, string sig)
Invoked by managed code to acquire a function pointer to a native JNI method.
Definition JNIFrame.cs:43

◆ open0()

static void IKVM.Java.Externs.java.io.FileOutputStream.open0 ( object this_,
string path,
bool append )
static

Implements the native method 'open0'.

Parameters
this_
path
append

Definition at line 44 of file FileOutputStream.cs.

45 {
46#if FIRST_PASS
47 throw new NotImplementedException();
48#else
49 if (JVM.Vfs.IsPath(path))
50 {
51 try
52 {
53 var fd = FileOutputStreamAccessor.GetFd(this_);
54 if (fd == null)
55 throw new global::java.io.IOException("The handle is invalid.");
56
57 FileDescriptorAccessor.SetPtr(fd, -1);
58 FileDescriptorAccessor.SetStream(fd, JVM.Vfs.Open(path, append ? FileMode.Append : FileMode.Create, FileAccess.Write));
59 }
60 catch (ObjectDisposedException e)
61 {
62 throw new global::java.io.IOException(e.Message);
63 }
64 catch (ArgumentException e)
65 {
66 throw new global::java.io.FileNotFoundException(e.Message);
67 }
68 catch (SecurityException e)
69 {
70 throw new global::java.lang.SecurityException(e.Message);
71 }
72 catch (UnauthorizedAccessException)
73 {
74 throw new global::java.io.FileNotFoundException(path + " (Access is denied)");
75 }
76 catch (IOException e)
77 {
78 throw new global::java.io.FileNotFoundException(e.Message);
79 }
80 catch (NotSupportedException e)
81 {
82 throw new global::java.io.FileNotFoundException(e.Message);
83 }
84 }
85 else
86 {
87 __callerID ??= global::ikvm.@internal.CallerID.create(typeof(global::java.io.FileOutputStream).TypeHandle);
88 __jniPtr__open0 ??= Marshal.GetDelegateForFunctionPointer<__jniDelegate__open0>(JNIFrame.GetFuncPtr(__callerID, "java/io/FileOutputStream", nameof(open0), "(Ljava/lang/String;Z)V"));
89 var jniFrm = new JNIFrame();
90 var jniEnv = jniFrm.Enter(__callerID);
91 try
92 {
93 var selfRef = jniFrm.MakeLocalRef(this_);
94 var pathRef = jniFrm.MakeLocalRef(path);
95 __jniPtr__open0(jniEnv, selfRef, pathRef, append ? JNIEnv.JNI_TRUE : JNIEnv.JNI_FALSE);
96 }
97 catch (Exception ex)
98 {
99 System.Console.WriteLine("*** exception in native code ***");
100 System.Console.WriteLine(ex);
101 throw;
102 }
103 finally
104 {
105 jniFrm.Leave();
106 }
107 }
108#endif
109 }
static void open0(object this_, string path, bool append)
Implements the native method 'open0'.
Main state of the running JVM.

◆ write()

static void IKVM.Java.Externs.java.io.FileOutputStream.write ( object self,
int byte_,
bool append )
static

Implements the native method 'write'.

Parameters
self
byte_
append

Definition at line 117 of file FileOutputStream.cs.

118 {
119#if FIRST_PASS
120 throw new NotImplementedException();
121#else
122 var fd = FileOutputStreamAccessor.GetFd(self);
123 if (fd == null)
124 throw new global::java.io.IOException("The handle is invalid.");
125
126 if (FileDescriptorAccessor.GetStream(fd) is Stream stream)
127 {
128 if (stream.CanWrite == false)
129 throw new global::java.io.IOException("The handle is invalid.");
130
131 try
132 {
133 stream.WriteByte((byte)byte_);
134 stream.Flush();
135 }
136 catch (ObjectDisposedException e)
137 {
138 throw new global::java.io.IOException(e.Message);
139 }
140 catch (NotSupportedException e)
141 {
142 throw new global::java.io.IOException(e.Message);
143 }
144 catch (IOException e)
145 {
146 throw new global::java.io.IOException(e.Message);
147 }
148 }
149 else
150 {
151 __callerID ??= global::ikvm.@internal.CallerID.create(typeof(global::java.io.FileOutputStream).TypeHandle);
152 __jniPtr__write ??= Marshal.GetDelegateForFunctionPointer<__jniDelegate__write>(JNIFrame.GetFuncPtr(__callerID, "java/io/FileOutputStream", nameof(write), "(IZ)V"));
153 var jniFrm = new JNIFrame();
154 var jniEnv = jniFrm.Enter(__callerID);
155 try
156 {
157 var selfRef = jniFrm.MakeLocalRef(self);
158 __jniPtr__write(jniEnv, selfRef, byte_, append ? JNIEnv.JNI_TRUE : JNIEnv.JNI_FALSE);
159 }
160 catch (Exception ex)
161 {
162 System.Console.WriteLine("*** exception in native code ***");
163 System.Console.WriteLine(ex);
164 throw;
165 }
166 finally
167 {
168 jniFrm.Leave();
169 }
170 }
171#endif
172 }
static void write(object self, int byte_, bool append)
Implements the native method 'write'.

◆ writeBytes()

static void IKVM.Java.Externs.java.io.FileOutputStream.writeBytes ( object self,
byte[] bytes,
int off,
int len,
bool append )
static

Implements the native method 'writeBytes'.

Parameters
self
bytes
off
len
append

Definition at line 182 of file FileOutputStream.cs.

183 {
184#if FIRST_PASS
185 throw new NotImplementedException();
186#else
187 var fd = FileOutputStreamAccessor.GetFd(self);
188 if (fd == null)
189 throw new global::java.io.IOException("The handle is invalid.");
190
191 if (FileDescriptorAccessor.GetStream(fd) is Stream stream)
192 {
193 if ((off < 0) || (off > bytes.Length) || (len < 0) || (len > (bytes.Length - off)))
194 throw new global::java.lang.IndexOutOfBoundsException();
195
196 if (stream.CanWrite == false)
197 throw new global::java.io.IOException("The handle is invalid.");
198
199 try
200 {
201 stream.Write(bytes, off, len);
202 stream.Flush();
203 }
204 catch (ObjectDisposedException e)
205 {
206 throw new global::java.io.IOException(e.Message);
207 }
208 catch (NotSupportedException e)
209 {
210 throw new global::java.io.IOException(e.Message);
211 }
212 catch (IOException e)
213 {
214 throw new global::java.io.IOException(e.Message);
215 }
216 }
217 else
218 {
219 __callerID ??= global::ikvm.@internal.CallerID.create(typeof(global::java.io.FileOutputStream).TypeHandle);
220 __jniPtr__writeBytes ??= Marshal.GetDelegateForFunctionPointer<__jniDelegate__writeBytes>(JNIFrame.GetFuncPtr(__callerID, "java/io/FileOutputStream", nameof(writeBytes), "([BIIZ)V"));
221 var jniFrm = new JNIFrame();
222 var jniEnv = jniFrm.Enter(__callerID);
223 try
224 {
225 __jniPtr__writeBytes(jniEnv, jniFrm.MakeLocalRef(self), jniFrm.MakeLocalRef(bytes), off, len, append ? JNIEnv.JNI_TRUE : JNIEnv.JNI_FALSE);
226 }
227 catch (Exception ex)
228 {
229 System.Console.WriteLine("*** exception in native code ***");
230 System.Console.WriteLine(ex);
231 throw;
232 }
233 finally
234 {
235 jniFrm.Leave();
236 }
237 }
238#endif
239 }
static void writeBytes(object self, byte[] bytes, int off, int len, bool append)
Implements the native method 'writeBytes'.

The documentation for this class was generated from the following file: