473,406 Members | 2,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

java as/400 ifs question

Hi, all! Here's my question. There is a way to program
to copy a file from one directory to another on the AS/400 using the
installable file system classes(here's the ibm.s code folows)

My problem is that I need to copy files from NT network to as/400 ifs.
Please, give me some hints of how to use the existing code (this is my very
first java assignment)
//Thanks in advance and please, cc: your reply to my e-mail:
ta********@yahoo.ca
NT

import java.io.*;
import java.util.*;
import com.ibm.as400.access.*;

public class IFSCopyFile extends Object
{
public static void main(String[] parameters)
{
System.out.println( " " );

String sourceName = "";
String targetName = "";
String system = "";
byte[] buffer = new byte[1024 * 64];

IFSFileInputStream source = null;
IFSFileOutputStream target = null;

// if all three parameters were not specified, display help text and
exit.

if (parameters.length > 2)
{

// Assume the first parameter is the system name,
// the second parameter is the source name and
// the third parameter is the target name.

system = parameters[0];
sourceName = parameters[1];
targetName = parameters[2];

try
{
// Create an AS400 object for the AS/400 system that holds the
files.

AS400 as400 = new AS400(system);

// Open the source file for exclusive access.

source = new IFSFileInputStream(as400,
sourceName,
IFSFileInputStream.SHARE_NONE);

System.out.println("Source file successfully opened");

// Open the target file for exclusive access.

target = new IFSFileOutputStream(as400,
targetName,
IFSFileOutputStream.SHARE_NONE,
false);

System.out.println("Target file successfully opened");

// Read the first 64K bytes from the source file.

int bytesRead = source.read(buffer);

// While there is data in the source file copy the data from
// the source file to the target file.

while (bytesRead > 0)
{
target.write(buffer, 0, bytesRead);
bytesRead = source.read(buffer);
}

System.out.println("Data successfully copied");

// Clean up by closing the source and target files.

source.close();
target.close();

// Get the last changed date/time from the source file and
// set it on the target file.

IFSFile src = new IFSFile(as400, sourceName);
long dateTime = src.lastModified();

IFSFile tgt = new IFSFile(as400, targetName);
tgt.setLastModified(dateTime);

System.out.println("Date/Time successfully set on target file");
System.out.println("Copy Successful");

}
catch (Exception e)
{
// If any of the above operations failed say the copy failed
// and output the exception.

System.out.println("Copy failed");
System.out.println(e);
}
}

// Display help text when parameters are incorrect.

else
{
System.out.println("");
System.out.println("");
System.out.println("");
System.out.println("Parameters are not correct. Command syntax
is:");
System.out.println("");
System.out.println(" IFSCopyFile as400 source target");
System.out.println("");
System.out.println("Where");
System.out.println("");
System.out.println(" as400 = system that contains the files");
System.out.println(" source = source file in /path/path/name
format");
System.out.println(" target = target file in /path/path/name
format");
System.out.println("");
System.out.println("For example:");
System.out.println("");
System.out.println(" IFSCopyFile myAS400 /dir1/dir2/a.txt
/dir3/b.txt");
System.out.println("");
System.out.println("");
}

System.exit(0);
}
}
Jul 17 '05 #1
0 4866

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

28
by: gmcdanie | last post by:
I am looking for a Java Decompiler... preferably free. Any suggestions. Ease of use isn't a problem as long as it does a fair job.
73
by: RobertMaas | last post by:
After many years of using LISP, I'm taking a class in Java and finding the two roughly comparable in some ways and very different in other ways. Each has a decent size library of useful utilities...
6
by: John Smith | last post by:
Hello, I have a rather odd question. My company is an all java/oracle shop. We do everything is Java... no matter what it is... parsing of text files, messaging, gui you name it. My question...
114
by: Maurice LING | last post by:
This may be a dumb thing to ask, but besides the penalty for dynamic typing, is there any other real reasons that Python is slower than Java? maurice
133
by: Gaurav | last post by:
http://www.sys-con.com/story/print.cfm?storyid=45250 Any comments? Thanks Gaurav
9
by: babylon | last post by:
i just read this (http://java.sun.com/developer/technicalArticles/releases/j2se15/) am I correcting on these concepts? Java Metadata == C# Attribute (java learn from c#?) Java Generics == C#...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
15
by: himilecyclist | last post by:
My State government organization has written a PHP/MySQL application which has been in production for about 6 months and has been highly successful. We are now embarking on a similar database...
0
by: Aaron J. Margosis | last post by:
I'm not a Java programmer, but I'm trying to solve some application compatibility issues with locked down security settings on Windows. My question: How do different Java-delivery tools invoke...
63
by: s0suk3 | last post by:
I've been programming Python for a couple of years now. Now I'm looking to move on to either C++ or Java, but I'm not sure which. Which one do you think will be a better transition for a Python...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.