473,659 Members | 2,645 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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********@yaho o.ca
NT

import java.io.*;
import java.util.*;
import com.ibm.as400.a ccess.*;

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

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

IFSFileInputStr eam source = null;
IFSFileOutputSt ream target = null;

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

if (parameters.len gth > 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 IFSFileInputStr eam(as400,
sourceName,
IFSFileInputStr eam.SHARE_NONE) ;

System.out.prin tln("Source file successfully opened");

// Open the target file for exclusive access.

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

System.out.prin tln("Target file successfully opened");

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

int bytesRead = source.read(buf fer);

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

while (bytesRead > 0)
{
target.write(bu ffer, 0, bytesRead);
bytesRead = source.read(buf fer);
}

System.out.prin tln("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.lastModifie d();

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

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

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

System.out.prin tln("Copy failed");
System.out.prin tln(e);
}
}

// Display help text when parameters are incorrect.

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

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

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

Similar topics

28
5124
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
7993
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 as a standard portable part of the core language, the LISP package, and the java.lang package, respectively. Both have big integers, although only LISP has rationals as far as I can tell. Because CL supports keyword arguments, it has a wider range...
6
5944
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 is this... is Perl so much better at parsing text files and outputing that we would see a substantial speed increase? We process about 10 million records in flat files a day for reformatting before putting them in a DB. Also, when it comes to...
114
9820
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
8530
by: Gaurav | last post by:
http://www.sys-con.com/story/print.cfm?storyid=45250 Any comments? Thanks Gaurav
9
1809
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# Generics (any other difference?i heard that C#'s generic is faster) Java autoboxing == C# autoboxing (java learn from c#?) java enchanced for == C# foreach ( (java learn from c#?) java enumerated type == c# enum (java learn from c#?) java static...
1
9623
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 and I was wondering if anyone here would be able to give me some tips for young players such as myself, for learning the language. Is this the best Newsgroup for support with JAVA?
15
10493
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 application, but one with much higher security concerns (birth data). Prior to beginning the project, we met with an oversight committee who strongly advised against PHP and suggested Java. Their concern was that PHP could not be trusted to...
0
2201
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 client-side Java in their HTML? Is the <APPLETtag the way they usually go, or do they use another mechanism? E.g., invoking it as an ActiveX via <OBJECT>? Through some kind of scripted invocation? Some other tag? One specific: what does...
63
4953
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 programmer? Which one will educate me the best?
0
8428
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8341
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8851
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8539
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8630
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7360
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5650
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4176
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4342
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.