Can't compile with FileFactory.newInputStream

General discussion on the JZOS batch launcher and toolkit
Post Reply
EarlHodil
Posts: 18
Joined: Thu Jan 17, 2013 1:46 pm

Can't compile with FileFactory.newInputStream

Post by EarlHodil »

I'm sure this is something stupid, but I've looked at it for two hours now and can't see it. I can't seem to get my program to compile using newInputStream. I have the ibmjzos.jar and jzos.jar files in my CLASSPATH, and I have the import com.ibm.jzos.FileFactory.*; Still no love.

Here's the code:

Code: Select all

import com.ibm.jzos.FileFactory.*;

import java.text.ParseException;
import java.text.SimpleDateFormat;

public class ProdAuth {
    
	private static long TENDAYS = 10*24*60*60*1000;
	
	public static void main(String[] args) throws Exception, UnsupportedEncodingException, ParseException {
		loadAuth();
		System.exit(0);
	}
	
	public static void loadAuth() {
    	try {
            //load a properties file
    		Properties prop = new Properties();
    		InputStream in = 
    				new com.ibm.jzos.FileFactory.newInputStream("//DD:AUTHPROP");
    		prop.load(in);
            //get the property value and print it out
            System.out.println(prop.getProperty("authcode"));
            in.close();
    	} catch (IOException ex) {
    		ex.printStackTrace();
        }
	}
And here's what I get when I use Ant to compile:

Code: Select all

compile:
     [echo] Classpath=/Users/ehodil/Documents/workspace/Memocast/lib/OSinfo.jar:/Users/ehodil/Documents/workspace/Memocast/lib/base64coder.jar:/Users/ehodil/Documents/workspace/Memocast/lib/ibmjzos.jar:/Users/ehodil/Documents/workspace/Memocast/lib/jzos.jar:/Users/ehodil/Documents/workspace/Memocast/lib/submit.jar
    [javac] /Users/ehodil/Documents/workspace/Memocast/deploy.xml:39: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
    [javac] Compiling 1 source file to /Users/ehodil/Documents/workspace/Memocast/bin
    [javac] /Users/ehodil/Documents/workspace/Memocast/src/com/OST/memocast/ProdAuth.java:58: cannot find symbol
    [javac] symbol  : class newInputStream
    [javac] location: class com.ibm.jzos.FileFactory
    [javac]     				new com.ibm.jzos.FileFactory.newInputStream("//DD:AUTHPROP");
    [javac]     				                            ^
    [javac] 1 error
I have quadruple checked my spelling. What am I doing wrong?
dovetail
Site Admin
Posts: 2022
Joined: Thu Jul 29, 2004 12:12 pm

Re: Can't compile with FileFactory.newInputStream

Post by dovetail »

com.ibm.jzos.FileFactory.newInputStream is a static method, not a constructor.
So, you shouldn't have "new".

Also, if you use newInputStream you will read the dataset in binary.
If you use Properties.load(InputStream), the data is expected to be in ASCII (ISO8859-1).

So, you might want to use one of the FileFactory static methods that returns a Reader (BufferedReader).
EarlHodil
Posts: 18
Joined: Thu Jan 17, 2013 1:46 pm

Re: Can't compile with FileFactory.newInputStream

Post by EarlHodil »

Thanks that worked (the newBufferedReader, that is).
Post Reply