corejava第10版
This commit is contained in:
1 parent
2021c3c227
commit
6165543dd3
1088 files changed
+94411
No files matched your search
@@ -0,0 +1,35 @@
|
||||
package compiler;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import javax.tools.*;
|
||||
|
||||
/**
|
||||
* A Java class that holds the bytecodes in a byte array.
|
||||
* @version 1.00 2007-11-02
|
||||
* @author Cay Horstmann
|
||||
*/
|
||||
public class ByteArrayJavaClass extends SimpleJavaFileObject
|
||||
{
|
||||
private ByteArrayOutputStream stream;
|
||||
|
||||
/**
|
||||
* Constructs a new ByteArrayJavaClass.
|
||||
* @param name the name of the class file represented by this file object
|
||||
*/
|
||||
public ByteArrayJavaClass(String name)
|
||||
{
|
||||
super(URI.create("bytes:///" + name), Kind.CLASS);
|
||||
stream = new ByteArrayOutputStream();
|
||||
}
|
||||
|
||||
public OutputStream openOutputStream() throws IOException
|
||||
{
|
||||
return stream;
|
||||
}
|
||||
|
||||
public byte[] getBytes()
|
||||
{
|
||||
return stream.toByteArray();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user