Yes, here is a sample, mainly from IBM Java samples, to copy a file 

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;

import com.ibm.jzos.FileFactory;

/**
 * Sample program that uses the FileFactory class to copy a text file or 
dataset.
 * The input and output file names are given as arguments to main, 
 * and they main be either POSIX (HFS) file names or MVS dataset names.
 * <p>
 * If the target file is an MVS dataset, then its LRECL should be compatible
 * with the source file/dataset. 
 * <p>
 * Example file names:
 * <ul>
 * <li>/etc/profile</li>
 * <li>//DD:INPUT</li>
 * <li>//'SYS1.MACLIB(ABEND)'</li>
 * <li>//MY.DATASET</li>
 * </ul>
 * 
 * @see com.ibm.jzos.FileFactory
 */
public class FileFactoryCopy {

           public static void copy(String[] args) throws IOException {
                if (args.length != 2) {
                        System.out.println("Usage: inputfileOrDataset 
outputFileOrDataset");
                        System.exit(8);
                }
                BufferedReader rdr = null;
                BufferedWriter wtr = null;
                long count = 0;
                        try {
                                rdr = FileFactory.newBufferedReader(args[0]);
                                wtr = FileFactory.newBufferedWriter(args[1]);
                        
                                String line;
                                while ((line = rdr.readLine()) != null) {
                                        wtr.write(line);
                                        wtr.write("\n");
                                        count++;
                                }
                                System.out.println("Copied " + count + " lines 
from: " + args[0] + " to: " + args[1] );
                        } finally {
                                if (wtr != null) wtr.close();
                                if (rdr != null) rdr.close();
                        }
            }
}

-----Original Message-----
From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf 
Of Cameron Conacher
Sent: Thursday, January 10, 2019 5:50 PM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Re: Do I need to copy a mainframe flat file to OMVS, before I access 
the data from a JAVA program?

Thank you Jerry.
Do I simply add a normal DD statement identifying my file?

//MYFILE DD DSN=HLQ.MYFILE,DISP=OLD



On Thu, Jan 10, 2019 at 4:42 PM Matt Hogstrom <m...@hogstrom.org> wrote:

> I haven’t verified this but I think you can reference the file in Java 
> using this convention for the file name from USS and not have to run 
> in an STC.  I’ll try this later tonight but thought I’d offer it 
> unverified if you have time.  Concur with Jerry on encoding.
>
> "//‘hlq.my.mvs.filename'"
>
> If you’re interested in z/OS specific capabilities via Java on the 
> platform look here:
>
>
> https://www.ibm.com/support/knowledgecenter/en/SSYKE2_7.1.0/com.ibm.ja
> va.zsecurity.api.71.doc/com.ibm.jzos/index.html
>
> Matt Hogstrom
> m...@hogstrom.org
> PGP Key: 0x90ECB270
>
> "Aut Inveniam Viam Aut Faciam" translated - "I shall either find a way 
> or make one."
>
> The phrase has been attributed to Hannibal < 
> http://en.wikipedia.org/wiki/Hannibal>; when his generals told him it 
> was impossible to cross the Alps by elephant < 
> http://en.wikipedia.org/wiki/Second_Punic_War>,
>
> > On Jan 10, 2019, at 4:35 PM, Edgington, Jerry <
> jerry.edging...@westernsouthernlife.com> wrote:
> >
> >
> > No you don't need to copy the file to USS, if you are running a Java
> batch job. JCL something like this, which executes the JVM procedure, 
> in this case Java 1.8 64bit. The STDENV DD will need the environment 
> variables, like LIBPATH, CLASSPATH, Java Options,etc.
> >
> > //JAVA EXEC PROC=JVMPRC86,
> > //    REGSIZE='1024M',
> > //    JAVACLS='-jar "directory path"/"name of Java program
> compiled".jar'
> > //*
> > //MAINARGS DD DUMMY
> > //STDENV   DD *
> > export PATH=/bin:"${JAVA_HOME}"/bin
> > LIBPATH=/lib:/usr/lib:"${JAVA_HOME}"/bin
> > LIBPATH="$LIBPATH":"${JAVA_HOME}"/lib/s390x
> > LIBPATH="$LIBPATH":"${JAVA_HOME}"/lib/s390x/j9vm
> > export LIBPATH="$LIBPATH":
> > CLASSPATH=$CLASSPATH:${JAVA_HOME}"/lib:"${JAVA_HOME}"/lib/ext
> > export CLASSPATH="$CLASSPATH":
> > # Configure JVM options
> > IJO="-Xms16m -Xmx128m"
> >
> > As far as encoding, you will need to in account for that in your 
> > Java
> program during the read.
> >
> > Hope that helps.  Also, the OMVS segment is a RACF term for the 
> > security
> definitions when you access USS either via 3270 or something like SSH.
> >
> > Jerry
> >
> > -----Original Message-----
> > From: IBM Mainframe Discussion List 
> > [mailto:IBM-MAIN@LISTSERV.UA.EDU]
> On Behalf Of Cameron Conacher
> > Sent: Thursday, January 10, 2019 4:11 PM
> > To: IBM-MAIN@LISTSERV.UA.EDU
> > Subject: Do I need to copy a mainframe flat file to OMVS, before I
> access the data from a JAVA program?
> >
> > Hello Listers,
> > If I have created a flat file in some mainframe batch JOB, and I 
> > want to
> pass it through a JAVA Utility, do I need to copy the file first to my 
> OMVS segment, and the run my JAVA process?
> > Or can I directly access the EBCDIC encoded flat file by my JAVA process?
> >
> > Just starting down this path.
> > Not really sure where I am going with this yet, or what I will do 
> > when I
> get there.
> >
> > Thank
> >
> > --------------------------------------------------------------------
> > -- For IBM-MAIN subscribe / signoff / archive access instructions, 
> > send
> email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
> >
> > --------------------------------------------------------------------
> > -- For IBM-MAIN subscribe / signoff / archive access instructions, 
> > send email to lists...@listserv.ua.edu with the message: INFO 
> > IBM-MAIN
>
>
> ----------------------------------------------------------------------
> For IBM-MAIN subscribe / signoff / archive access instructions, send 
> email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
>

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions, send email to 
lists...@listserv.ua.edu with the message: INFO IBM-MAIN

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to