Cannot write the suitable source codes for running program

I want to write a program that help student to compile program and run program by using some test cases. For the compiled part, i have been wrote it successfully, but for the run part, i cannot pass the test cases to the program for running. Could any ppl help me to find the problem on the followng codes, why the error will on there? how do i change it? Thanks!
//<!--start get Program Test Case File-->
java.io.BufferedReader TestCaseBuf = null;
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:compas", "sa", "password");
stmt = con.createStatement();
String strSQL = "SELECT testValue FROM TEST_CASE WHERE progID='"+progID+"'";
stmt = con.createStatement();
rs = stmt.executeQuery(strSQL);
try
while (rs.next())
TestCaseBuf = new java.io.BufferedReader(new java.io.InputStreamReader(rs.getBinaryStream("testValue")));                         
finally
if (rs != null)
     rs.close();
if (stmt != null)
     stmt.close();
//<!--end get Program Test Case File-->
//<!--start run program -->
String[ ] args2 = new String[ ]
     "java", "-cp", System.getProperty("user.dir"), FileName
try
     Runtime rt = Runtime.getRuntime();
     Process proc = rt.exec(args2);
     java.io.BufferedReader ireader = new java.io.BufferedReader(new java.io.InputStreamReader(proc.getInputStream()));
     java.io.PrintWriter pwriter = new java.io.PrintWriter(proc.getOutputStream());
String atestcase = null;
     String line= null;
     try
while ((atestcase = TestCaseBuf.readLine()) != null) <------------I found that error seems on here!!!!
     pwriter.write(atestcase+"\r");
pwriter.flush();     
if (atestcase != null)
          if ((line = ireader.readLine()) != null)
          FileOutput = FileOutput + line +"\r\n";
else {break; }
     } //while
     catch (java.io.IOException e)
     out.println("[IOException]. Printing Stack Trace");
     e.printStackTrace();
     pwriter.close();
     ireader.close();
catch (java.io.IOException e)
out.println("[IOException]. Printing Stack Trace");
e.printStackTrace();
//<!--end run program -->

Whats the error message??
Just a guess, but could be (without seeing the error) that you've already closed the TestCaseBuf reader by closing the result set, hence when you go to read it, you're reading on closed reader.
Give this a go...Put the //<!--run program --> code into the result set while loop
while (rs.next())
TestCaseBuf = new java.io.BufferedReader(new java.io.InputStreamReader(rs.getBinaryStream("testValue")));
//<!--start run program -->
...some code
//<!--end run program -->
} Hard to tell without the error message

Similar Messages

  • How can I download the full source code for the Java 3D package

    how can I download the full source code for javax.media.j3d
    especially I need the Transform3D.java class.
    thanks a lot
    Meir

    thank you guys I'll try to do so, I suggest you to
    join me.From the one of the (ex-!)Java3D team:
    "I'm glad to see that Sun has decided to officially support an
    open source Java/OpenGL binding, JOGL. Perhaps they will
    eventually decide to make Java 3D open source. However, be
    careful what you wish for. The Java 3D source is huge and
    complex. There are native sections for Solaris, Windows/OpenGL,
    and Windows/Direct3D, plus common code. I don't know how you'd
    open source a build process that requires different pieces of
    the code be built on different machines running different
    operating systems."
    Sounds scary - I hope we're ready for it :)

  • How to edit the html source code for my site

    I have just started a blog, and am VERY new to it. I am trying to edit the html source code on my site (ie, to insert google adsense search bars). I go to my blog site, get to page source and see the html but I am not able to edit it. Not sure what I am doing wrong. Thanks!

    You can use any editor you want mine is set up for notepad.exe
    :see http://dmcritchie.mvps.org/firefox/firefox.htm#notepad
    :to invoke use "Ctrl+U" or View > Page Source
    :this is for sites that you maintain on your local drives or servers, and copy over to a website.

  • Dbx cannot locate the (DLM) source codes correctly for 64bit app

    It's hard for me to prepare a test case. Because it seems for a simple "hello world" it works.
    The reason I raise this issue here is because my project was recently upgraded to compile with 64bit. And since then dbx cannot locate the source codes correctly, especially for some DLM codes. (sometimes it shows to "/usr/include/iso/..." which it should never be!). While it works fine on a 32bit compiled mode.
    Did anyone experience the similar situation and can share your idea?
    Thanks in advance.

    Can't think of any good reason why going to 64 bit would confuse dbx (except for unknown bug in dbx, which is not impossible).
    I'd first look for changes in your build - for example, 32-bit code used to go to bin/ directory, but 64-bit goes to bin/sparcv9, which happens to be a symlink somewhere else or something like that. Symlinks might sometimes confuse dbx, please read
    (dbx) help finding-filestopic (in dbx console, type "help finding-files").
    Since you are using CC 5.9 that generates DWARF info by default, location and even presence of .o files is not important. All debug info should be in the shared library itself.
    Here's another idea: inspect DWARF info by hand and see if it looks correct to you.
    $ dwarfdump a.out | lessLook for
                    DW_AT_name                  a.ccand
                    DW_AT_comp_dir              /home/maxim/tempThose two should give location of source file (/home/maxim/temp/a.cc in my case). Maybe this will give you some clue.

  • How to understand the Vector source code for function elements()?

    hello all:
    This following code snippet is extracted from java.util.Vector source code.
    who can tell me how i can understand what the function nextElement does?
    thank you
    public Enumeration elements() {
         return new Enumeration() {
             int count = 0;
             public boolean hasMoreElements() {
              return count < this.num_elem;
             public Object nextElement() {
              synchronized (Vector.this) {   //???
                  if (count < elementCount) {//???
                   return elementData[count++];
              throw new NoSuchElementException("Vector Enumeration");
        }

    Perhaps code would help more. This codeimport java.util.Vector;
    import java.util.Enumeration;
    import java.util.Iterator;
    public class Test {
        public static void main(String[] arghs) {
         Vector v = new Vector();
         Integer two = new Integer(2);
         // Fill the Vector
         v.add("One");
         v.add(two);
         v.add(new StringBuffer("Three"));
         // Enumerate through the objects in the vector
         System.out.println("---- Enumeration ----");
         Enumeration e = v.elements();
         while (e.hasMoreElements()) System.out.println(e.nextElement());
         // Loop through the objects in the vector
         System.out.println("---- Loop ----");
         for (int i=0; i<v.size(); i++) System.out.println(v.get(i));
         // Iterate through the objects in the vector
         System.out.println("---- Iterator ----");
         Iterator i = v.iterator();
         while (i.hasNext()) System.out.println(i.next());
    }produces this output
    ---- Enumeration ----
    One
    2
    Three
    ---- Loop ----
    One
    2
    Three
    ---- Iterator ----
    One
    2
    Three
    So, for a Vector, all three do the same thing. However, Iterator is part of the Collection Framework (see [url http://java.sun.com/j2se/1.4.2/docs/guide/collections/index.html]here). This allows you to treat a whole bunch of [url http://java.sun.com/j2se/1.4.2/docs/guide/collections/reference.html]objects which implement the Collection interface all the same way. I know this is way more than you were asking, but I hope it at least clears up what you were asking.

  • Is it possible to compile a VI so it contains all of the necessary source code to run and no longer needs to have access to the SubVIs?

    I would like to take a high level VI and compile it so it contains all of the subVI code, but is no longer editable. Students will be able to use the high level VI and won't have to have access to all of the SubVIs.

    Thanks! I think I am making progress.
    The code I am calling is a dialog box and it uses a global variable to pass calibration information.
    Here is what I have done so far.
    I built a shared DLL. I added my VI as an exported VI.
    I used C calling conventions. I added 4 parameters (connection ID for TCP communication in and out) and sensor array (information on the configuration of a sensor) in and out.
    I built a wrapper for the shared library (attached).
    The dialog box doesn't open and I get either a hang or an error saying that LabVIEW has been corrupted.
    I am hoping that I am making an obvious mistake!
    Thanks again for your help!
    Attachments:
    calibrator_wrapper.vi ‏37 KB

  • How to write the pl/sql code for this scenario

    Hi,
    Here is the data in a Table with below colums
    id firstname lastname code
    1 scott higgins 001
    2 Mike Ferrari 001
    3 Tom scottsdale 002
    4 Nick pasquale 003
    1 scott higgins 004
    I want to trap the following exceptions into an error table using pl/sql
    1. same person having multiple code
    example
    id first last Code
    1 scott higgins 001
    1 scott higgins 004
    2. Multiple persons having same code
    id first last Code
    1 scott higgins 001
    2 Mike Ferrari 001
    Could you please help me how to capture the exceptions above using pl/sql
    and what will be the structure of error table. it should capture eff date & end date

    or using analytic functions like this:
    select id, fname, lname, code from (
    with t as(
        select 1 id, 'scott' fname, 'higgins' lname, 001 code from dual
        union all
        select 2 id,'Mike ' fname, 'Ferrari' lname,  001  code from dual
        union all
        select 3 id,'Tom' fname, 'scottsdale' lname, 002  code from dual
        union all
        select 4 id,'Nick' fname, 'pasquale' lname, 003  code from dual
        union all
        select 5 id,'scott' fname, 'higgins' lname, 004  code from dual
        select t.*, count(*) over (partition by fname) row_count from t)
    where row_count > 1;
    select id, fname, lname, code from (
    with t as(
        select 1 id, 'scott' fname, 'higgins' lname, 001 code from dual
        union all
        select 2 id,'Mike ' fname, 'Ferrari' lname,  001  code from dual
        union all
        select 3 id,'Tom' fname, 'scottsdale' lname, 002  code from dual
        union all
        select 4 id,'Nick' fname, 'pasquale' lname, 003  code from dual
        union all
        select 5 id,'scott' fname, 'higgins' lname, 004  code from dual
        select t.*, count(*) over (partition by code) row_count from t)
    where row_count > 1;

  • Request to give source code for beans program and its implementation method

    I need beans program with two beans Traffic Light( Implemented as a bacground colors- Red, Green, Yellow) and Automobile ( Implemented as a Text box which states its state/movement) the state of the Automobile should depend on the following Light Transition Table
    Light Transition Automobile State
    Red --> Yellow Ready
    Yellow ---> Green Move
    Green --> Red Stopped

    Homework?

  • Where do i find open source code for the FF Sync capability ?

    Where can i find the open source code for the FoxFire capability "Sync" (bookmarks)....
    That capability should be extended to allow one or more (selectable) arbitrary sync servers; I want to look into providing such capability, with enhancements.

    Sign in, activation, or connection errors | CS5.5 and later
    Redemption Code Help
    Mylenium

  • Need Sample source code for Forum in jsp

    Hi..
    Please tell me the website which is having the sample source code for simple forum... I have to implement it into my project... kindly help me out...
    thanx in advance
    kumar

    Hi..
    Please tell me the website which is having the sample source code for simple forum... I have to implement it into my project... kindly help me out...
    thanx in advance
    kumar

  • How to get full source code for Oracle ADF?

    Hi,
    I 'm referring to the following URL http://download-west.oracle.com/docs/html/B25947_01/intro003.htm and it has mentioned that full source for Oracle ADF is available :
    "Full source for Oracle ADF is available to supported customers through Oracle Worldwide Support. The full source code for the framework can be an important tool to assisting you in diagnosing problems and in correctly extending the base framework functionality for your needs."
    Does anyone know how to obtain such information from Oracle support? Is this from metalink

    One possible snag in the process is that you will have some legal paperwork to sign. Depending on your company's policies, this could pose a problem.
    Erik

  • Source Code for Business Package Assets

    If anyone customized I would like to know how to get to the Java source code for Asset Business Package
    Regards
    Mike

    Augustine Vinish wrote:
    Hi Team ,
    I have find out the source code of the Package from dba_source at text column .
    How can I find out
    *1 .where the Database is mounted ie Server information and*
    *2 .Name of the Sql file contains the package body*
    *3 .location of the file in the Server*
    Regards ,
    AugustineHi - the source code isn't read in from a file by the database, it's actually stored in the database itself (have a look at the user_source view). Now you may have text files backups of your source code, that have been used previously to create the packages, but the database won't store any info about the file used to do this.

  • Source Code for Asset Business Package

    If anyone customized I would like to know how to get to the Java source code for Asset Business Package
    Regards
    Mike

    Try the SCSL release:http://www.sun.com/software/communitysource/j2se/java2/download.xml

  • How to display the source code for this friggin' file.

    Below is a rather lengthy bit of code that provides the behavior and attributes of a web server for OpenCyc. I need to know if I can enter some java to have the HTML source code displayed in a separate text file whenever this class returns some resulting webpage. If you have any ideas it will be greatly appreciated.
    -"Will code for foo."
    package org.opencyc.webserver;
    * Class WebServer is simple multithreaded HTTP server
    * with CGI limited to a Cyc connection on default port 3600.
    * <p>
    import java.net.*;
    import java.io.*;
    import java.util.*;
    import java.util.jar.*;
    import java.text.*;
    import org.opencyc.util.*;
    public class WebServer extends Thread {
         * Singleton WebServer instance.
        public static WebServer current;
         * Default HTTP port.
        protected static int DEFAULT_PORT = 80;
         * Default Cyc base port.
        protected static int DEFAULT_CYC_PORT = 3600;
         * Default directory to serve files from on non-Windows OS.
        protected static String DEFAULT_DIR = "/";
         * Default directory to serve files from on Windows.
        //protected static String DEFAULT_WIN_DIR = "C:\\";
        protected static String DEFAULT_WIN_DIR = "k:\\opencyc\\run\\httpd\\htdocs";
         * File cache capacity.
        protected static final int CACHE_CAPACITY = 100;
         * File cache to improve file serving performance.
        protected static Hashtable fileCache = new Hashtable(CACHE_CAPACITY);
         * Number of files served from this web server.
        protected static long nbrFilesServed = 0;
         * Number of files served from this web server that were found in the cache.
        protected static long nbrCacheHits = 0;
         * Server socket for accepting connections.
        protected ServerSocket server;
         * Directories to serve files from.
        protected ArrayList dirs;
         * Map from String (jar root) to JarFile[] (jar class path).
        protected HashMap map;
         * Webserver HTTP port.
        protected int port;
         * Cyc HTML host.
        protected String cycHost = "localhost";
         * Cyc HTML port.
        protected int cycPort;
         * Expand jar tress.
        protected boolean trees;
         * Requests flag.
        protected boolean traceRequests;
         * Constructs a WebServer object.
         * @param port the port to use
         * @param directories the directory to serve files from
         * @param trees true if files within jar files should be served up
         * @param traceRequests true if client's request text should be logged.
         * @exception IOException if the listening socket cannot be opened, or problem opening jar files.
        public WebServer() throws IOException {
            getProperties();
            server = new ServerSocket(port);
            processDirectories();
         * Class Task processes a single HTTP request.
        protected class Task extends Thread {
             * Socket for the incoming request.
            protected Socket sock;
             * Client socket to the Cyc KB HTML server.
            protected Socket cycHtmlSocket;
             * Output tcp stream.
            protected DataOutputStream out;
             * Contains the file request path for a not-found error message.
            protected String notFoundPath;
             * Contains the first line of a request message.
            protected String methodLine;
             * Contains the body of a POST method.
            protected String bodyLine;
             * Constructs a Task object.
             * @param sock the socket assigned for this request.
            public Task(Socket sock) {
                this.sock = sock;
             * Processes the HTTP request.
            public void run() {
                if (traceRequests)
                    Log.current.println("connection accepted from " + sock.getInetAddress());
                notFoundPath = "";
                try {
                    out = new DataOutputStream(sock.getOutputStream());
                    try {
                        getBytes();
                    catch (Exception e) {
                        Log.current.println("file not found: " + notFoundPath);
                        try {
                            out.writeBytes("HTTP/1.1 404 Not Found\r\n");
                            out.writeBytes("Server: Cyc WebServer\r\n");
                            out.writeBytes("Connection: close\r\n");
                            out.writeBytes("Content-Type: text/html\r\n\r\n");
                            out.writeBytes("<HTML><HEAD>\n");
                            out.writeBytes("<TITLE>404 Not Found</TITLE>\n");
                            out.writeBytes("</HEAD><BODY>\n");
                            out.writeBytes("<H1>404 - Not Found</H1>\n");
                            out.writeBytes("</BODY></HTML>");
                            out.flush();
                        catch (SocketException se) {
                catch (Exception e) {
                    Log.current.printStackTrace(e);
                finally {
                    try {
                        sock.close();
                    catch (IOException e) {
             * Reads the HTTP request and obtains the response.
             * @exception IOException when HTTP request has an invalid format.
            private void getBytes() throws IOException {
                // Below logic is complex because web browsers do not close the
                // socket after sending the request, so must parse message to find
                // the end.
                BufferedReader in = new BufferedReader(new InputStreamReader(sock.getInputStream()));
                ArrayList inBytes = new ArrayList(200);
                int ch = 0;
                boolean postMethod;
                methodLine = in.readLine();
                //if (traceRequests)
                //    Log.current.println("methodLine=" + methodLine);
                bodyLine = "";
                if (methodLine.startsWith("POST /"))
                    postMethod = true;
                else
                    postMethod = false;
                //if (traceRequests)
                //    Log.current.println("postMethod=" + postMethod);
                int ch1 = -1;
                int ch2 = -1;
                int ch3 = -1;
                int ch4 = -1;
                // Read the HTTP request headers.
                while (true) {
                    ch = in.read();
                    inBytes.add(new Integer(ch));
                    ch1 = ch2;
                    ch2 = ch3;
                    ch3 = ch4;
                    ch4 = ch;
                    if (ch1 == '\r' && ch2 == '\n' && ch3 == '\r' && ch4 == '\n')
                        break;
                    if ((! postMethod) &&
                        (! in.ready()) &&
                        ch1 == -1 &&
                        ch2 == -1 &&
                        ch3 == '\r' &&
                        ch4 == '\n') {
                        inBytes.add(new Integer('\r'));
                        inBytes.add(new Integer('\n'));
                        break;
                byte[] byteArray = new byte[inBytes.size()];
                for (int i = 0; i < inBytes.size(); i++) {
                    Integer ich = (Integer) inBytes.get(i);
                    byteArray[i] = ich.byteValue();
                String headers = new String(byteArray);
                if (postMethod) {
                    String lcHeaders = headers.toLowerCase();
                    int i = lcHeaders.indexOf("content-length: ");
                    String contentLength = lcHeaders.substring(i + 16);
                    int j = contentLength.indexOf("\r\n");
                    contentLength = contentLength.substring(0, j);
                    int bodyLen = (new Integer(contentLength)).intValue();
                    for (int k = 0; k < bodyLen; k++) {
                        bodyLine = bodyLine + (new Character((char) in.read())).toString();
                String line = methodLine + "\r\n" + headers + bodyLine;
                if (traceRequests)
                    Log.current.println(line);
                if (postMethod)
                    processHttpPost();
                else
                    if (line.startsWith("GET /"))
                        processHttpGet(line.substring(4));
                    else {
                        Log.current.println("Invalid request = " + line);
                        throw new IOException();
             * Processes an HTTP GET method.
             * @param httpGetPath the path of the file to get.
             * @exception IOException if the file is not found.
            private void processHttpGet(String httpGetPath) throws IOException {
                int i = httpGetPath.indexOf(' ');
                if (i > 0)
                    httpGetPath = httpGetPath.substring(0, i);
                Log.current.println(methodLine + " from " + sock.getInetAddress().getHostName());
                i = httpGetPath.indexOf("cg?");
                if (i > 0) {
                    cycHtmlRequest(httpGetPath.substring(i + 3));
                    return;
                notFoundPath = httpGetPath;
                i = httpGetPath.indexOf('/');
                if (i < 0 || map == null) {
                    if (map == null || httpGetPath.endsWith(".jar")) {
                        for (int j = 0; j < dirs.size(); j++) {
                            String dir = (String) dirs.get(j);
                            String nativePath = dir + httpGetPath;
                            nativePath = nativePath.replace('/', File.separatorChar);
                            if (fileCache.containsKey(nativePath)) {
                                writeDataBytes((byte[]) fileCache.get(nativePath));
                                Log.current.println("...cached");
                                nbrCacheHits++;
                                nbrFilesServed++;
                                return;
                            try {
                                File f = new File(nativePath);
                                byte[] fileBytes = getBytes(new FileInputStream(f), f.length());
                                writeDataBytes(fileBytes);
                                if (fileCache.size() >= CACHE_CAPACITY)
                                    fileCache.clear();
                                fileCache.put(nativePath, fileBytes);
                                Log.current.println("...from " + nativePath);
                                nbrFilesServed++;
                                return;
                            catch (IOException e) {
                    throw new IOException();
                String jar = httpGetPath.substring(0, i);
                httpGetPath = httpGetPath.substring(i + 1);
                JarFile[] jfs = (JarFile[]) map.get(jar);
                if (jfs == null)
                    throw new IOException();
                for (i = 0; i < jfs.length; i++) {
                    JarEntry je = jfs.getJarEntry(httpGetPath);
    if (je == null)
    continue;
    writeDataBytes(getBytes(jfs[i].getInputStream(je), je.getSize()));
    nbrFilesServed++;
    return;
    throw new IOException();
    * Processes an HTTP POST method.
    * @exception IOException if the file is not found.
    private void processHttpPost() throws IOException {
    Log.current.println("POST " + bodyLine + " from " + sock.getInetAddress().getHostName());
    cycHtmlRequest(bodyLine);
    * Reads the specified number of bytes and always close the stream.
    * @param in the file to be read for subsequent downloading.
    * @param length the number of bytes to read from the file.
    * @return An array of bytes from the file.
    * @exception IOException if an error occurs when processing the file.
    private byte[] getBytes(InputStream in, long length) throws IOException {
    DataInputStream din = new DataInputStream(in);
    byte[] bytes = new byte[ (int) length];
    try {
    din.readFully(bytes);
    finally {
    din.close();
    return bytes;
    * Sends the HTML request to Cyc.
    * @param cycPath the portion of the URL which is given to the Cyc HTML server.
    private void cycHtmlRequest(String cycPath) {
    String request = sock.getInetAddress().getHostName() + "&" + cycPath + "#";
    System.out.println("request=" + request);
    ArrayList bytes = new ArrayList(10000);
    try {
    cycHtmlSocket = new Socket(cycHost, cycPort);
    System.out.println("cycHost=" + cycHost + " cycPort=" + cycPort);
    BufferedReader cycIn = new BufferedReader(new InputStreamReader(cycHtmlSocket.getInputStream()));
    PrintWriter cycOut = new PrintWriter(cycHtmlSocket.getOutputStream(), true);
    cycOut.println(request);
    cycOut.flush();
    int ch = 0;
    while (ch >= 0) {
    ch = cycIn.read();
    bytes.add(new Integer(ch));
    catch (Exception e) {
    Log.current.printStackTrace(e);
    byte[] byteArray = new byte[bytes.size()];
    for (int i = 0; i < bytes.size() - 1; i++) {
    Integer ich = (Integer) bytes.get(i);
    byteArray[i] = ich.byteValue();
    try {
    writeTextBytes(byteArray);
    catch (Exception e) {
    Log.current.println(e.getMessage());
    * Responds to the HTTP client with data content from the requested URL.
    * @param bytes the array of bytes from the URL.
    * @exception IOException if there is an error writing to the HTTP client.
    public void writeDataBytes(byte[] bytes) throws IOException {
    out.writeBytes("HTTP/1.1 200 OK\r\n");
    out.writeBytes("Server: Cyc WebServer\r\n");
    out.writeBytes("Connection: close\r\n");
    out.writeBytes("Content-Length: " + bytes.length + "\r\n");
    String prefix = (new String(bytes)).toLowerCase();
    if (prefix.indexOf("<html>") > -1)
    out.writeBytes("Content-Type: text/html\r\n\r\n");
    else
    out.writeBytes("Content-Type: application/java\r\n\r\n");
    out.write(bytes);
    out.flush();
    * Respond to the HTTP client with text content from the requested URL.
    * @param bytes the array of bytes from the URL.
    * @exception IOException if there is an error writing to the HTTP client.
    public void writeTextBytes(byte[] bytes) throws IOException {
    out.writeBytes("HTTP/1.1 200 OK\r\n");
    out.writeBytes("Server: Cyc WebServer\r\n");
    out.writeBytes("Connection: close\r\n");
    out.writeBytes("Content-Length: " + bytes.length + "\r\n");
    out.writeBytes("Content-Type: text/html\r\n\r\n");
    out.write(bytes);
    out.flush();
    * Gets properties governing the web server's behavior.
    private void getProperties() {
    port = DEFAULT_PORT;
    String portProperty = System.getProperty("org.opencyc.webserver.port", "");
    if (! portProperty.equalsIgnoreCase(""))
    port = (new Integer(portProperty)).intValue();
    Log.current.println("Listening on port " + port);
    cycPort = DEFAULT_CYC_PORT;
    String cycPortProperty = System.getProperty("org.opencyc.webserver.cycPort", "");
    if (! cycPortProperty.equalsIgnoreCase(""))
    cycPort = (new Integer(cycPortProperty)).intValue();
    Log.current.println("Cyc connections directed to port " + cycPort);
    String dirsProperty = System.getProperty("org.opencyc.webserver.dirs", "");
    dirs = new ArrayList(3);
    StringTokenizer st = new StringTokenizer(dirsProperty, ";", false);
    while (st.hasMoreTokens()) {
    String dir = st.nextToken();
    dirs.add(dir);
    trees = false;
    String treesProperty = System.getProperty("org.opencyc.webserver.trees", "");
    if (! treesProperty.equalsIgnoreCase(""))
    trees = true;
    traceRequests = false;
    String traceRequestsProperty = System.getProperty("org.opencyc.webserver.traceRequests", "");
    if (! traceRequestsProperty.equalsIgnoreCase("")) {
    traceRequests = true;
    Log.current.println("tracing requests");
    * Adds transitive Class-Path jars to jfs.
    * @param jar the jar file
    * @param jfs the list of jar files to serve.
    * @param dir the jar file directory.
    * @exception IOException if an I/O error has occurred with the jar file.
    private void addJar(String jar, ArrayList jfs, String dir) throws IOException {
    Log.current.println("Serving jar files from: " + dir + jar);
    JarFile jf = new JarFile(dir + jar);
    jfs.add(jf);
    Manifest man = jf.getManifest();
    if (man == null)
    return;
    Attributes attrs = man.getMainAttributes();
    if (attrs == null)
    return;
    String val = attrs.getValue(Attributes.Name.CLASS_PATH);
    if (val == null)
    return;
    dir = dir + jar.substring(0, jar.lastIndexOf(File.separatorChar) + 1);
    StringTokenizer st = new StringTokenizer(val);
    while (st.hasMoreTokens()) {
    addJar(st.nextToken().replace('/', File.separatorChar), jfs, dir);
    * Administrative accessor method that obtains list of directories from which files are served.
    public ArrayList getDirs() {
    return dirs;
    * Administrative method that updates the list of directories from which files are served.
    public synchronized void setDirs(ArrayList dirs) throws IOException {
    this.dirs = dirs;
    fileCache.clear();
    processDirectories();
    * Administrative accessor method that obtains number of files served.
    * @return The number of files served.
    public long getNbrFilesServed() {
    return nbrFilesServed;
    * Administrative accessor method that obtains number of files served from cache.
    * @return The number of files served from the cache.
    public long getNbrCacheHits() {
    return nbrCacheHits;
    * Administrative method that clears the file cache.
    public synchronized void clearFileCache() {
    Log.current.println("Clearing file cache");
    fileCache.clear();
    nbrFilesServed = 0;
    nbrCacheHits = 0;
    * Processes the directories from which files are served, expanding jar trees if
    * directed.
    * @exception IOException if problem occurs while processing the jar files.
    private void processDirectories() throws IOException {
    if (dirs.size() == 0)
    if (File.separatorChar == '\\')
    dirs.add(DEFAULT_WIN_DIR);
    else
    dirs.add(DEFAULT_DIR);
    Iterator directories = dirs.iterator();
    while (directories.hasNext())
    Log.current.println("Serving from " + directories.next());
    if (trees) {
    map = new HashMap();
    for (int j = 0; j < dirs.size(); j++) {
    String dir = (String) dirs.get(j);
    String[] files = new File(dir).list();
    for (int i = 0; i < files.length; i++) {
    String jar = files[i];
    if (!jar.endsWith(".jar"))
    continue;
    ArrayList jfs = new ArrayList(1);
    addJar(jar, jfs, dir);
    map.put(jar.substring(0, jar.length() - 4), jfs.toArray(new JarFile[jfs.size()]));
    * Provides the command line interface for creating an HTTP server.
    * The properties are:
    * <pre>
    * org.opencyc.webserver.port=<HTTP listening port>
    * </pre>
    * which defaults to 80.
    * <pre>
    * org.opencyc.webserver.cycPort=<Cyc connection port>
    * </pre>
    * which defaults to 3600.
    * <pre>
    * org.opencyc.webserver.dirs=<path>;<path> ... ;<path>
    * </pre>
    * with the argument enclosed in quotes if any path contains an
    * embedded space.
    * The default directory on Windows is C:
    * and the default on other systems is / the default
    * can be overridden with this property. By default, all files
    * under this directory (including all subdirectories) are served
    * up via HTTP. If the pathname of a file is <var>path</var> relative
    * to the top-level directory, then the file can be downloaded using
    * the URL
    * <pre>
    * http://<var>host</var>:<var>port</var>/<var>path</var>
    * </pre>
    * Caching of file contents is performed.
    * <pre>
    * org.opencyc.util.log=all
    * </pre>
    * If the all value is given, then all attempts to download files
    * are output.
    * <pre>
    * org.opencyc.webserver.traceRequests
    * </pre>
    * If this property has any value, then the client HTTP requests are
    * output.<p>
    * <pre>
    * org.opencyc.webserver.trees
    * </pre>
    * This property can be used to serve up individual files stored
    * within jar files in addition to the files that are served up by
    * default. If the property has any value, the server finds all jar files
    * in the top-level directory (not in subdirectories). For each
    * jar file, if the name of the jar file is <var>name</var>.jar, then any
    * individual file named <var>file</var> within that jar file (or within
    * the jar or zip files referenced transitively in the Class-Path manifest
    * attribute, can be downloaded using a URL of the form:
    * <pre>
    * http://<var>host</var>:<var>port</var>/<var>name</var>/<var>file</var>
    * </pre>
    * When this property has any value, an open file descriptor and cached
    * information are held for each jar file, for the life of the process.
    * @param args an unused array of command line arguments.
    public static void main(String[] args) {
    Log.makeLog();
    System.out.println("OpenCyc Web Server");
    try {
    // Launch thread to accept HTTP connections.
    current = new WebServer();
    current.start();
    catch (IOException e) {
    e.printStackTrace();
    * Just keep looping, spawning a new thread for each incoming request.
    public void run() {
    try {
    while (true) {
    // Launch thread to process one HTTP request.
    new Task(server.accept()).start();
    catch (IOException e) {
    e.printStackTrace();

    JLundan,
    I want to thank you for responding to the thread I started on the forum at java.sun.com. Your solution to my problem of needing to print the code of the html pages that the file I included generates was just what I was looking for. However, I have some further questions to ask, if you don't mind. To clarify my task I should say that your rephrasing of the problem is accurate: "You wan't to display the contents of the HTML file that the web server produces in response of client's request?"
    Yes, this is what I need to do, but also it needs to display the source code of that html file that the server produces in response to the client's request. Also, in this case, I am the client requesting that the server return some html file, and I'm not sure where the server is. But the webserver.java file that I shared on the forum is on my local machine. I was wondering if I could modify this webserver.java file at my home so that any html file the server returns to me would automatically display the source code. This is a school project of mine and I am stuck on this one thing here.
    Further, where would I put the "foo.html" file so it can be written to?
    FileOuputStream fos = new FileOutputStream("foo.html");
    fos.write(bytes);
    fos.close();
    Thanks so much for your help. I look forward to your response, at your convenience.
    Regards

  • Batch code for running a find/replace all on multiple files within a source floder/directory

    What I need is a Batch source code that will open all files in a folder/directory and run a find and replace_all query within them and then save all the files.  The files were created in Illustrator and saved using the Scene7 FXG format extension.    These files will be uploaded into Scene7 as a group after the find and replace macro/query is run on the code.  The same find and replace query will be the same for all the files.  Basically this function or batch process  will save time in setting the same parameters all at one time instead of having to set the parameters individually in scene7.
    a source code sample of the find/replace module macro might be              searchString:  s7:colorvalue="#FFFFFFFF" 
                                                                                                                          replaceString: s7:colorValue="#&txtclr;"
                                                                                                                          searchWhat   "FXG document"    
                                                                                                                             searchSource:  true,
                                                                                                                        useRegularExpressions:   true
    I have no problems creating batch files within Ai and PhotoShop but I have limited programming skills in how to create source code for manuipulating documents outside of those apps or in a OS invironment.
    I could probably come up witha simple program to do what i want for one document but i get lost when dealing with multiple documents in a source folder (prolbem is,  I will be dealing with thousands of documents not 100 or less)
    If anything which Adope cloud app would work best:  Dreamweaver or Edge code   (or just use my notepad)

    What I need is a Batch source code that will open all files in a folder/directory and run a find and replace_all query within them and then save all the files.  The files were created in Illustrator and saved using the Scene7 FXG format extension.    These files will be uploaded into Scene7 as a group after the find and replace macro/query is run on the code.  The same find and replace query will be the same for all the files.  Basically this function or batch process  will save time in setting the same parameters all at one time instead of having to set the parameters individually in scene7.
    a source code sample of the find/replace module macro might be              searchString:  s7:colorvalue="#FFFFFFFF" 
                                                                                                                          replaceString: s7:colorValue="#&txtclr;"
                                                                                                                          searchWhat   "FXG document"    
                                                                                                                             searchSource:  true,
                                                                                                                        useRegularExpressions:   true
    I have no problems creating batch files within Ai and PhotoShop but I have limited programming skills in how to create source code for manuipulating documents outside of those apps or in a OS invironment.
    I could probably come up witha simple program to do what i want for one document but i get lost when dealing with multiple documents in a source folder (prolbem is,  I will be dealing with thousands of documents not 100 or less)
    If anything which Adope cloud app would work best:  Dreamweaver or Edge code   (or just use my notepad)

Maybe you are looking for

  • Error updating a CLOB XML fragment

    Hi, I have an xml schema that contains an element of type xs:anyType that has been mapped to Oracle as CLOB. Now I have the needs to update this value but I was not able to do it. The code that does the update is the following: public void updateXML(

  • When I add text to a PDF, I am forced to change the file name rather than just updating the current file.  Why?

    I have been doing the same process for months and until recently I could just add text to a pdf, click save, adobe would ask me if I wanted to replace the current file, I'd say yes and we would be done.  Now I get a message that says "The document co

  • A New Forms Look and Feel?

    http://groundside.com/blog/GrantRonald?title=new_forms_look_and_feel_interview_with_f&more=1&c=1&tb=1&pb=1 might be of interest. grant

  • Long running job

    Hi Guru's I've created generic datasource using structure and FM.I've chacked in rsa3 it's working fine but when I schedule INIT from bw it's still in yellow status and 1672 from 0 records on monitor screen. The records are in psa. Please advise what

  • Can precalc server run in multiple SAP systems ?

    We are running the precalc server multiinstance on a 64 bit server.  Can we have the precalc server identified in 2 SAP systems ?.  IE precalc_server1 in our production BIP system and QA System, BIQ.  I thought I read that this was not standard pract