|
From: <cr...@us...> - 2008-11-09 08:08:30
|
Revision: 4686
http://jnode.svn.sourceforge.net/jnode/?rev=4686&view=rev
Author: crawley
Date: 2008-11-09 08:08:19 +0000 (Sun, 09 Nov 2008)
Log Message:
-----------
Changing commands to use 'execute()' and PrintWriters were appropriate
Modified Paths:
--------------
trunk/fs/src/fs/org/jnode/fs/command/DirCommand.java
trunk/fs/src/fs/org/jnode/fs/command/EjectCommand.java
trunk/fs/src/fs/org/jnode/fs/command/HexdumpCommand.java
trunk/fs/src/fs/org/jnode/fs/command/MkdirCommand.java
trunk/fs/src/fs/org/jnode/fs/command/MountCommand.java
trunk/fs/src/fs/org/jnode/fs/command/PwdCommand.java
trunk/fs/src/fs/org/jnode/fs/command/TouchCommand.java
trunk/fs/src/fs/org/jnode/fs/ftpfs/command/FTPMountCommand.java
trunk/fs/src/fs/org/jnode/fs/jfat/command/JGrub.java
trunk/fs/src/fs/org/jnode/fs/jfat/command/JGrubInstallCommand.java
trunk/fs/src/fs/org/jnode/fs/jifs/command/CreateJIFSCommand.java
trunk/fs/src/fs/org/jnode/fs/nfs/command/NFSMountCommand.java
trunk/fs/src/fs/org/jnode/fs/smbfs/command/SMBMountCommand.java
trunk/fs/src/fs/org/jnode/partitions/command/FdiskCommand.java
trunk/fs/src/fs/org/jnode/partitions/command/PartitionHelper.java
trunk/net/src/net/org/jnode/net/command/ArpCommand.java
trunk/net/src/net/org/jnode/net/command/BootpCommand.java
trunk/net/src/net/org/jnode/net/command/DhcpCommand.java
trunk/net/src/net/org/jnode/net/command/IfconfigCommand.java
trunk/net/src/net/org/jnode/net/command/NetstatCommand.java
trunk/net/src/net/org/jnode/net/command/PingCommand.java
trunk/net/src/net/org/jnode/net/command/ResolverCommand.java
trunk/net/src/net/org/jnode/net/command/RouteCommand.java
trunk/net/src/net/org/jnode/net/command/RpcInfoCommand.java
trunk/net/src/net/org/jnode/net/command/TcpInoutCommand.java
trunk/net/src/net/org/jnode/net/command/TftpCommand.java
trunk/net/src/net/org/jnode/net/command/WLanCtlCommand.java
trunk/net/src/net/org/jnode/net/command/WgetCommand.java
trunk/net/src/net/org/jnode/net/ipv4/tftp/TFTPClient.java
Modified: trunk/fs/src/fs/org/jnode/fs/command/DirCommand.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/command/DirCommand.java 2008-11-09 03:32:20 UTC (rev 4685)
+++ trunk/fs/src/fs/org/jnode/fs/command/DirCommand.java 2008-11-09 08:08:19 UTC (rev 4686)
@@ -23,15 +23,13 @@
import java.io.File;
import java.io.IOException;
-import java.io.InputStream;
-import java.io.PrintStream;
+import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Date;
import org.jnode.shell.AbstractCommand;
-import org.jnode.shell.CommandLine;
import org.jnode.shell.syntax.Argument;
import org.jnode.shell.syntax.FileArgument;
@@ -58,12 +56,14 @@
new DirCommand().execute(args);
}
- public void execute(CommandLine commandLine, InputStream in, PrintStream out, PrintStream err)
+ public void execute()
throws IOException {
File[] paths = ARG_PATH.getValues();
if (paths.length == 0) {
paths = new File[] {new File(System.getProperty("user.dir"))};
}
+ PrintWriter out = getOutput().getPrintWriter(false);
+ PrintWriter err = getError().getPrintWriter();
for (File path : paths) {
if (!path.exists()) {
err.println("No such path: " + path);
@@ -81,7 +81,7 @@
}
}
- private void printList(File[] list, PrintStream out) {
+ private void printList(File[] list, PrintWriter out) {
if (list != null) {
Arrays.sort(list, new Comparator<File>() {
public int compare(File f1, File f2) {
Modified: trunk/fs/src/fs/org/jnode/fs/command/EjectCommand.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/command/EjectCommand.java 2008-11-09 03:32:20 UTC (rev 4685)
+++ trunk/fs/src/fs/org/jnode/fs/command/EjectCommand.java 2008-11-09 08:08:19 UTC (rev 4686)
@@ -22,14 +22,11 @@
package org.jnode.fs.command;
import java.io.IOException;
-import java.io.InputStream;
-import java.io.PrintStream;
import org.jnode.driver.ApiNotFoundException;
import org.jnode.driver.Device;
import org.jnode.driver.RemovableDeviceAPI;
import org.jnode.shell.AbstractCommand;
-import org.jnode.shell.CommandLine;
import org.jnode.shell.syntax.Argument;
import org.jnode.shell.syntax.DeviceArgument;
@@ -52,14 +49,14 @@
new EjectCommand().execute(args);
}
- public void execute(CommandLine commandLine, InputStream in, PrintStream out, PrintStream err)
+ public void execute()
throws ApiNotFoundException, IOException {
final Device dev = ARG_DEVICE.getValue();
final RemovableDeviceAPI api = dev.getAPI(RemovableDeviceAPI.class);
try {
api.eject();
} catch (IOException ex) {
- err.println("eject failed for " + dev.getId() + ": " + ex.getMessage());
+ getError().getPrintWriter().println("eject failed for " + dev.getId() + ": " + ex.getMessage());
exit(1);
}
}
Modified: trunk/fs/src/fs/org/jnode/fs/command/HexdumpCommand.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/command/HexdumpCommand.java 2008-11-09 03:32:20 UTC (rev 4685)
+++ trunk/fs/src/fs/org/jnode/fs/command/HexdumpCommand.java 2008-11-09 08:08:19 UTC (rev 4686)
@@ -9,11 +9,10 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
-import java.io.PrintStream;
+import java.io.PrintWriter;
import java.net.URL;
import org.jnode.shell.AbstractCommand;
-import org.jnode.shell.CommandLine;
import org.jnode.shell.syntax.Argument;
import org.jnode.shell.syntax.FileArgument;
import org.jnode.shell.syntax.URLArgument;
@@ -39,9 +38,11 @@
new HexdumpCommand().execute(args);
}
- public void execute(CommandLine commandLine, InputStream in, PrintStream out, PrintStream err)
- throws IOException {
+ public void execute() throws IOException {
+ boolean myInput = false;
InputStream is = null;
+ PrintWriter out = getOutput().getPrintWriter(false);
+ PrintWriter err = getError().getPrintWriter();
try {
// Set up the stream to be dumped.
File file = ARG_FILE.getValue();
@@ -61,7 +62,8 @@
exit(1);
}
} else {
- is = in;
+ is = getInput().getInputStream();
+ myInput = true;
}
// Now do the work
@@ -122,7 +124,7 @@
}
out.flush();
} finally {
- if (is != null && is != in) {
+ if (is != null && myInput) {
try {
is.close();
} catch (IOException ex) {
Modified: trunk/fs/src/fs/org/jnode/fs/command/MkdirCommand.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/command/MkdirCommand.java 2008-11-09 03:32:20 UTC (rev 4685)
+++ trunk/fs/src/fs/org/jnode/fs/command/MkdirCommand.java 2008-11-09 08:08:19 UTC (rev 4686)
@@ -22,11 +22,9 @@
package org.jnode.fs.command;
import java.io.File;
-import java.io.InputStream;
-import java.io.PrintStream;
+import java.io.PrintWriter;
import org.jnode.shell.AbstractCommand;
-import org.jnode.shell.CommandLine;
import org.jnode.shell.syntax.Argument;
import org.jnode.shell.syntax.FileArgument;
@@ -48,8 +46,9 @@
new MkdirCommand().execute(args);
}
- public void execute(CommandLine commandLine, InputStream in, PrintStream out, PrintStream err) {
+ public void execute() {
File dir = ARG_DIR.getValue();
+ PrintWriter err = getError().getPrintWriter();
if (dir.exists()) {
err.println(dir.getPath() + " already exists.");
exit(1);
Modified: trunk/fs/src/fs/org/jnode/fs/command/MountCommand.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/command/MountCommand.java 2008-11-09 03:32:20 UTC (rev 4685)
+++ trunk/fs/src/fs/org/jnode/fs/command/MountCommand.java 2008-11-09 08:08:19 UTC (rev 4686)
@@ -22,8 +22,7 @@
package org.jnode.fs.command;
import java.io.File;
-import java.io.InputStream;
-import java.io.PrintStream;
+import java.io.PrintWriter;
import java.util.Map;
import org.jnode.driver.Device;
@@ -32,7 +31,6 @@
import org.jnode.fs.service.FileSystemService;
import org.jnode.naming.InitialNaming;
import org.jnode.shell.AbstractCommand;
-import org.jnode.shell.CommandLine;
import org.jnode.shell.syntax.Argument;
import org.jnode.shell.syntax.DeviceArgument;
import org.jnode.shell.syntax.FileArgument;
@@ -60,11 +58,11 @@
new MountCommand().execute(args);
}
- public void execute(CommandLine commandLine, InputStream in,
- PrintStream out, PrintStream err) throws Exception {
+ public void execute() throws Exception {
// Find the filesystem service
final FileSystemService fss = InitialNaming.lookup(FileSystemService.NAME);
-
+ PrintWriter out = getOutput().getPrintWriter();
+ PrintWriter err = getError().getPrintWriter();
if (!ARG_DEV.isSet()) {
// List all mounted file systems
Map<String, FileSystem<?>> filesystems = fss.getMountPoints();
Modified: trunk/fs/src/fs/org/jnode/fs/command/PwdCommand.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/command/PwdCommand.java 2008-11-09 03:32:20 UTC (rev 4685)
+++ trunk/fs/src/fs/org/jnode/fs/command/PwdCommand.java 2008-11-09 08:08:19 UTC (rev 4686)
@@ -22,11 +22,8 @@
package org.jnode.fs.command;
import java.io.File;
-import java.io.InputStream;
-import java.io.PrintStream;
import org.jnode.shell.AbstractCommand;
-import org.jnode.shell.CommandLine;
/**
* @author Martin Husted Hartvig (ha...@jn...)
@@ -40,8 +37,8 @@
new PwdCommand().execute(args);
}
- public void execute(CommandLine commandLine, InputStream in, PrintStream out, PrintStream err) {
+ public void execute() {
File file = new File("");
- out.println(file.getAbsolutePath());
+ getOutput().getPrintWriter().println(file.getAbsolutePath());
}
}
Modified: trunk/fs/src/fs/org/jnode/fs/command/TouchCommand.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/command/TouchCommand.java 2008-11-09 03:32:20 UTC (rev 4685)
+++ trunk/fs/src/fs/org/jnode/fs/command/TouchCommand.java 2008-11-09 08:08:19 UTC (rev 4686)
@@ -22,11 +22,9 @@
package org.jnode.fs.command;
import java.io.File;
-import java.io.InputStream;
-import java.io.PrintStream;
+import java.io.PrintWriter;
import org.jnode.shell.AbstractCommand;
-import org.jnode.shell.CommandLine;
import org.jnode.shell.syntax.Argument;
import org.jnode.shell.syntax.FileArgument;
@@ -51,9 +49,10 @@
new TouchCommand().execute(args);
}
- public void execute(CommandLine commandLine, InputStream in, PrintStream out, PrintStream err)
- throws Exception {
+ public void execute() throws Exception {
File file = ARG_FILE.getValue();
+ PrintWriter out = getOutput().getPrintWriter();
+ PrintWriter err = getError().getPrintWriter();
if (!file.exists()) {
File parentFile = file.getParentFile();
if (parentFile != null && !parentFile.exists()) {
Modified: trunk/fs/src/fs/org/jnode/fs/ftpfs/command/FTPMountCommand.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ftpfs/command/FTPMountCommand.java 2008-11-09 03:32:20 UTC (rev 4685)
+++ trunk/fs/src/fs/org/jnode/fs/ftpfs/command/FTPMountCommand.java 2008-11-09 08:08:19 UTC (rev 4686)
@@ -22,18 +22,10 @@
package org.jnode.fs.ftpfs.command;
import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PrintStream;
-import javax.naming.NameNotFoundException;
-
import org.apache.log4j.Logger;
-import org.jnode.driver.DeviceAlreadyRegisteredException;
import org.jnode.driver.DeviceManager;
import org.jnode.driver.DeviceUtils;
-import org.jnode.driver.DriverException;
-import org.jnode.fs.FileSystemException;
import org.jnode.fs.ftpfs.FTPFSDevice;
import org.jnode.fs.ftpfs.FTPFSDriver;
import org.jnode.fs.ftpfs.FTPFileSystem;
@@ -41,7 +33,6 @@
import org.jnode.fs.service.FileSystemService;
import org.jnode.naming.InitialNaming;
import org.jnode.shell.AbstractCommand;
-import org.jnode.shell.CommandLine;
import org.jnode.shell.syntax.Argument;
import org.jnode.shell.syntax.FileArgument;
import org.jnode.shell.syntax.HostNameArgument;
@@ -72,10 +63,7 @@
new FTPMountCommand().execute(args);
}
- public void execute(CommandLine commandLine, InputStream in,
- PrintStream out, PrintStream err)
- throws DriverException, NameNotFoundException, DeviceAlreadyRegisteredException,
- FileSystemException, IOException {
+ public void execute() throws Exception {
final File mountPoint = MOUNTPOINT_ARG.getValue();
final String host = HOST_ARG.getValue();
final String user = USERNAME_ARG.getValue();
@@ -94,6 +82,9 @@
fss.registerFileSystem(fs);
fss.mount(mountPoint.getAbsolutePath(), fs, null);
ok = true;
+ } catch (Exception ex) {
+ getError().getPrintStream().println("FTP mount failed: " + ex.getLocalizedMessage());
+ throw ex;
} finally {
if (!ok) {
try {
Modified: trunk/fs/src/fs/org/jnode/fs/jfat/command/JGrub.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/jfat/command/JGrub.java 2008-11-09 03:32:20 UTC (rev 4685)
+++ trunk/fs/src/fs/org/jnode/fs/jfat/command/JGrub.java 2008-11-09 08:08:19 UTC (rev 4686)
@@ -23,7 +23,7 @@
package org.jnode.fs.jfat.command;
import java.io.File;
-import java.io.PrintStream;
+import java.io.PrintWriter;
import java.util.Map;
import javax.naming.NameNotFoundException;
@@ -48,18 +48,18 @@
* @author Tango Devian
*/
public class JGrub {
- private final PrintStream out;
+ private final PrintWriter out;
private final MBRFormatter stage1;
private final Stage1_5 stage1_5;
private final Stage2 stage2;
private final Device device;
private final String mountPoint;
- public JGrub(PrintStream out, PrintStream err, Device device) throws GrubException {
- this(out, err, device, new MBRFormatter(), new Stage1_5(), new Stage2());
+ public JGrub(PrintWriter out, Device device) throws GrubException {
+ this(out, device, new MBRFormatter(), new Stage1_5(), new Stage2());
}
- protected JGrub(PrintStream out, PrintStream err, Device device, MBRFormatter stage1,
+ protected JGrub(PrintWriter out, Device device, MBRFormatter stage1,
Stage1_5 stage1_5, Stage2 stage2) throws GrubException {
this.out = out;
this.stage1 = stage1;
Modified: trunk/fs/src/fs/org/jnode/fs/jfat/command/JGrubInstallCommand.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/jfat/command/JGrubInstallCommand.java 2008-11-09 03:32:20 UTC (rev 4685)
+++ trunk/fs/src/fs/org/jnode/fs/jfat/command/JGrubInstallCommand.java 2008-11-09 08:08:19 UTC (rev 4686)
@@ -22,13 +22,9 @@
package org.jnode.fs.jfat.command;
-import java.io.InputStream;
-import java.io.PrintStream;
-
import org.jnode.driver.Device;
import org.jnode.driver.block.BlockDeviceAPI;
import org.jnode.shell.AbstractCommand;
-import org.jnode.shell.CommandLine;
import org.jnode.shell.syntax.Argument;
import org.jnode.shell.syntax.DeviceArgument;
@@ -53,11 +49,11 @@
new JGrubInstallCommand().execute(args);
}
- public void execute(CommandLine commandLine, InputStream in, PrintStream out, PrintStream err)
+ public void execute()
throws GrubException {
Device device = ARG_DEVICE.getValue();
- JGrub jgrub = new JGrub(out, err, device);
+ JGrub jgrub = new JGrub(getOutput().getPrintWriter(), device);
jgrub.install();
}
}
Modified: trunk/fs/src/fs/org/jnode/fs/jifs/command/CreateJIFSCommand.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/jifs/command/CreateJIFSCommand.java 2008-11-09 03:32:20 UTC (rev 4685)
+++ trunk/fs/src/fs/org/jnode/fs/jifs/command/CreateJIFSCommand.java 2008-11-09 08:08:19 UTC (rev 4686)
@@ -21,9 +21,6 @@
package org.jnode.fs.jifs.command;
-import java.io.InputStream;
-import java.io.PrintStream;
-
import javax.naming.NameNotFoundException;
import org.jnode.naming.InitialNaming;
@@ -31,7 +28,6 @@
import org.jnode.plugin.PluginException;
import org.jnode.plugin.PluginManager;
import org.jnode.shell.AbstractCommand;
-import org.jnode.shell.CommandLine;
import org.jnode.shell.syntax.Argument;
import org.jnode.shell.syntax.EnumArgument;
@@ -66,8 +62,7 @@
registerArguments(ARG_ACTION);
}
- public void execute(CommandLine commandLine, InputStream in, PrintStream out, PrintStream err)
- throws NameNotFoundException, PluginException {
+ public void execute() throws NameNotFoundException, PluginException {
final PluginManager mgr = InitialNaming.lookup(PluginManager.NAME);
final Plugin p =
mgr.getRegistry().getPluginDescriptor("org.jnode.fs.jifs.def").getPlugin();
Modified: trunk/fs/src/fs/org/jnode/fs/nfs/command/NFSMountCommand.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/nfs/command/NFSMountCommand.java 2008-11-09 03:32:20 UTC (rev 4685)
+++ trunk/fs/src/fs/org/jnode/fs/nfs/command/NFSMountCommand.java 2008-11-09 08:08:19 UTC (rev 4686)
@@ -23,8 +23,6 @@
import java.io.File;
import java.io.IOException;
-import java.io.InputStream;
-import java.io.PrintStream;
import java.net.InetAddress;
import javax.naming.NameNotFoundException;
@@ -42,7 +40,6 @@
import org.jnode.naming.InitialNaming;
import org.jnode.net.nfs.Protocol;
import org.jnode.shell.AbstractCommand;
-import org.jnode.shell.CommandLine;
import org.jnode.shell.syntax.Argument;
import org.jnode.shell.syntax.FileArgument;
import org.jnode.shell.syntax.FlagArgument;
@@ -90,8 +87,7 @@
new NFSMountCommand().execute(args);
}
- public void execute(CommandLine commandLine, InputStream in, PrintStream out, PrintStream err)
- throws NameNotFoundException, DriverException, DeviceAlreadyRegisteredException,
+ public void execute() throws NameNotFoundException, DriverException, DeviceAlreadyRegisteredException,
FileSystemException, IOException {
final File mountPoint = MOUNTPOINT_ARG.getValue();
final InetAddress host = HOST_ARG.getAddress();
Modified: trunk/fs/src/fs/org/jnode/fs/smbfs/command/SMBMountCommand.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/smbfs/command/SMBMountCommand.java 2008-11-09 03:32:20 UTC (rev 4685)
+++ trunk/fs/src/fs/org/jnode/fs/smbfs/command/SMBMountCommand.java 2008-11-09 08:08:19 UTC (rev 4686)
@@ -22,8 +22,7 @@
package org.jnode.fs.smbfs.command;
import java.io.File;
-import java.io.InputStream;
-import java.io.PrintStream;
+
import org.jnode.driver.DeviceManager;
import org.jnode.driver.DeviceUtils;
import org.jnode.driver.DriverException;
@@ -34,7 +33,6 @@
import org.jnode.fs.smbfs.SMBFileSystemType;
import org.jnode.naming.InitialNaming;
import org.jnode.shell.AbstractCommand;
-import org.jnode.shell.CommandLine;
import org.jnode.shell.syntax.Argument;
import org.jnode.shell.syntax.FileArgument;
import org.jnode.shell.syntax.HostNameArgument;
@@ -65,8 +63,7 @@
new SMBMountCommand().execute(args);
}
- public void execute(CommandLine commandLine, InputStream in, PrintStream out, PrintStream err)
- throws Exception {
+ public void execute() throws Exception {
final File mountPoint = MOUNTPOINT_ARG.getValue();
final String host = HOST_ARG.getValue();
final String path = PATH_ARG.getValue();
Modified: trunk/fs/src/fs/org/jnode/partitions/command/FdiskCommand.java
===================================================================
--- trunk/fs/src/fs/org/jnode/partitions/command/FdiskCommand.java 2008-11-09 03:32:20 UTC (rev 4685)
+++ trunk/fs/src/fs/org/jnode/partitions/command/FdiskCommand.java 2008-11-09 08:08:19 UTC (rev 4686)
@@ -22,8 +22,7 @@
package org.jnode.partitions.command;
import java.io.IOException;
-import java.io.InputStream;
-import java.io.PrintStream;
+import java.io.PrintWriter;
import java.nio.ByteBuffer;
import java.util.Collection;
import java.util.List;
@@ -42,7 +41,6 @@
import org.jnode.partitions.ibm.IBMPartitionTableType;
import org.jnode.partitions.ibm.IBMPartitionTypes;
import org.jnode.shell.AbstractCommand;
-import org.jnode.shell.CommandLine;
import org.jnode.shell.syntax.Argument;
import org.jnode.shell.syntax.DeviceArgument;
import org.jnode.shell.syntax.FlagArgument;
@@ -100,10 +98,10 @@
new FdiskCommand().execute(args);
}
- public void execute(CommandLine commandLine, InputStream in,
- PrintStream out, PrintStream err) throws Exception {
+ public void execute() throws Exception {
final DeviceManager dm = InitialNaming.lookup(DeviceManager.NAME);
-
+ PrintWriter out = getOutput().getPrintWriter();
+ PrintWriter err = getError().getPrintWriter();
if (!ARG_DEVICE.isSet()) {
// Show all devices.
listAvailableDevices(dm, out);
@@ -143,7 +141,7 @@
return partNumber;
}
- private void modifyPartition(PartitionHelper helper, int id, PrintStream out) throws IOException {
+ private void modifyPartition(PartitionHelper helper, int id, PrintWriter out) throws IOException {
long start = ARG_START.getValue();
long size = ARG_SECTORS.isSet() ? ARG_SECTORS.getValue() : ARG_BYTES.getValue();
IBMPartitionTypes type = ARG_TYPE.getValue();
@@ -156,7 +154,7 @@
helper.modifyPartition(id, false, start, size, sizeUnit, type);
}
- private void printPartitionTable(Device dev, PrintStream out)
+ private void printPartitionTable(Device dev, PrintWriter out)
throws DeviceNotFoundException, ApiNotFoundException, IOException {
IDEDevice ideDev = null;
// FIXME ... this needs to be generalized to other disc device types.
@@ -208,7 +206,7 @@
}
}
- private void listAvailableDevices(DeviceManager dm, PrintStream out) {
+ private void listAvailableDevices(DeviceManager dm, PrintWriter out) {
final Collection<Device> allDevices = dm.getDevicesByAPI(BlockDeviceAPI.class);
for (Device dev : allDevices) {
out.println("Found device : " + dev.getId() + "[" + dev.getClass() + "]");
Modified: trunk/fs/src/fs/org/jnode/partitions/command/PartitionHelper.java
===================================================================
--- trunk/fs/src/fs/org/jnode/partitions/command/PartitionHelper.java 2008-11-09 03:32:20 UTC (rev 4685)
+++ trunk/fs/src/fs/org/jnode/partitions/command/PartitionHelper.java 2008-11-09 08:08:19 UTC (rev 4686)
@@ -1,7 +1,7 @@
package org.jnode.partitions.command;
import java.io.IOException;
-import java.io.PrintStream;
+import java.io.PrintWriter;
import javax.naming.NameNotFoundException;
@@ -32,14 +32,14 @@
private final MasterBootRecord MBR;
private BootSector bs;
- private final PrintStream out;
+ private final PrintWriter out;
- public PartitionHelper(String deviceId, PrintStream out) throws DeviceNotFoundException, ApiNotFoundException,
+ public PartitionHelper(String deviceId, PrintWriter out) throws DeviceNotFoundException, ApiNotFoundException,
IOException, NameNotFoundException {
this((IDEDevice) DeviceUtils.getDeviceManager().getDevice(deviceId), out);
}
- public PartitionHelper(IDEDevice device, PrintStream out) throws DeviceNotFoundException, ApiNotFoundException,
+ public PartitionHelper(IDEDevice device, PrintWriter out) throws DeviceNotFoundException, ApiNotFoundException,
IOException {
this.current = device;
this.api = current.getAPI(BlockDeviceAPI.class);
Modified: trunk/net/src/net/org/jnode/net/command/ArpCommand.java
===================================================================
--- trunk/net/src/net/org/jnode/net/command/ArpCommand.java 2008-11-09 03:32:20 UTC (rev 4685)
+++ trunk/net/src/net/org/jnode/net/command/ArpCommand.java 2008-11-09 08:08:19 UTC (rev 4686)
@@ -21,8 +21,7 @@
package org.jnode.net.command;
-import java.io.InputStream;
-import java.io.PrintStream;
+import java.io.PrintWriter;
import org.jnode.driver.net.NetworkException;
import org.jnode.net.NoSuchProtocolException;
@@ -31,7 +30,6 @@
import org.jnode.net.ethernet.EthernetConstants;
import org.jnode.net.util.NetUtils;
import org.jnode.shell.AbstractCommand;
-import org.jnode.shell.CommandLine;
import org.jnode.shell.syntax.Argument;
import org.jnode.shell.syntax.FlagArgument;
@@ -55,9 +53,10 @@
new ArpCommand().execute(args);
}
- public void execute(CommandLine commandLine, InputStream in,
- PrintStream out, PrintStream err) throws NoSuchProtocolException, NetworkException {
- ARPNetworkLayer arp = (ARPNetworkLayer) NetUtils.getNLM().getNetworkLayer(EthernetConstants.ETH_P_ARP);
+ public void execute() throws NoSuchProtocolException, NetworkException {
+ ARPNetworkLayer arp = (ARPNetworkLayer)
+ NetUtils.getNLM().getNetworkLayer(EthernetConstants.ETH_P_ARP);
+ PrintWriter out = getOutput().getPrintWriter();
if (FLAG_CLEAR.isSet()) {
arp.getCache().clear();
out.println("Cleared the ARP cache");
Modified: trunk/net/src/net/org/jnode/net/command/BootpCommand.java
===================================================================
--- trunk/net/src/net/org/jnode/net/command/BootpCommand.java 2008-11-09 03:32:20 UTC (rev 4685)
+++ trunk/net/src/net/org/jnode/net/command/BootpCommand.java 2008-11-09 08:08:19 UTC (rev 4686)
@@ -21,9 +21,6 @@
package org.jnode.net.command;
-import java.io.InputStream;
-import java.io.PrintStream;
-
import javax.naming.NameNotFoundException;
import org.jnode.driver.Device;
@@ -32,7 +29,6 @@
import org.jnode.naming.InitialNaming;
import org.jnode.net.ipv4.config.IPv4ConfigurationService;
import org.jnode.shell.AbstractCommand;
-import org.jnode.shell.CommandLine;
import org.jnode.shell.syntax.Argument;
import org.jnode.shell.syntax.DeviceArgument;
@@ -53,10 +49,9 @@
new BootpCommand().execute(args);
}
- public void execute(CommandLine commandLine, InputStream in,
- PrintStream out, PrintStream err) throws NameNotFoundException, NetworkException {
+ public void execute() throws NameNotFoundException, NetworkException {
final Device dev = ARG_DEVICE.getValue();
- out.println("Trying to configure " + dev.getId() + "...");
+ getOutput().getPrintWriter().println("Trying to configure " + dev.getId() + "...");
final IPv4ConfigurationService cfg = InitialNaming.lookup(IPv4ConfigurationService.NAME);
cfg.configureDeviceBootp(dev, true);
}
Modified: trunk/net/src/net/org/jnode/net/command/DhcpCommand.java
===================================================================
--- trunk/net/src/net/org/jnode/net/command/DhcpCommand.java 2008-11-09 03:32:20 UTC (rev 4685)
+++ trunk/net/src/net/org/jnode/net/command/DhcpCommand.java 2008-11-09 08:08:19 UTC (rev 4686)
@@ -21,8 +21,7 @@
package org.jnode.net.command;
-import java.io.InputStream;
-import java.io.PrintStream;
+import java.io.PrintWriter;
import java.net.InetAddress;
import java.net.UnknownHostException;
@@ -39,7 +38,6 @@
import org.jnode.net.ethernet.EthernetConstants;
import org.jnode.net.ipv4.config.IPv4ConfigurationService;
import org.jnode.shell.AbstractCommand;
-import org.jnode.shell.CommandLine;
import org.jnode.shell.syntax.Argument;
import org.jnode.shell.syntax.DeviceArgument;
@@ -61,8 +59,7 @@
new DhcpCommand().execute(args);
}
- public void execute(CommandLine commandLine, InputStream in, PrintStream out, PrintStream err)
- throws DeviceNotFoundException, NameNotFoundException, ApiNotFoundException,
+ public void execute() throws DeviceNotFoundException, NameNotFoundException, ApiNotFoundException,
UnknownHostException, NetworkException {
final Device dev = ARG_DEVICE.getValue();
@@ -75,13 +72,14 @@
NetDeviceAPI api = loopback.getAPI(NetDeviceAPI.class);
ProtocolAddressInfo info = api.getProtocolAddressInfo(EthernetConstants.ETH_P_IP);
if (info == null || !info.contains(InetAddress.getByAddress(new byte[]{127, 0, 0, 1}))) {
+ PrintWriter err = getError().getPrintWriter();
err.println("The loopback network device is not bound to IP address 127.0.0.1");
err.println("Run 'ifconfig loopback 127.0.0.1 255.255.255.255' to fix this.");
exit(1);
}
// Now it should be safe to do the DHCP configuration.
- out.println("Configuring network device " + dev.getId() + "...");
+ getOutput().getPrintWriter().println("Configuring network device " + dev.getId() + "...");
final IPv4ConfigurationService cfg = InitialNaming.lookup(IPv4ConfigurationService.NAME);
cfg.configureDeviceDhcp(dev, true);
}
Modified: trunk/net/src/net/org/jnode/net/command/IfconfigCommand.java
===================================================================
--- trunk/net/src/net/org/jnode/net/command/IfconfigCommand.java 2008-11-09 03:32:20 UTC (rev 4685)
+++ trunk/net/src/net/org/jnode/net/command/IfconfigCommand.java 2008-11-09 08:08:19 UTC (rev 4686)
@@ -21,8 +21,7 @@
package org.jnode.net.command;
-import java.io.InputStream;
-import java.io.PrintStream;
+import java.io.PrintWriter;
import javax.naming.NameNotFoundException;
@@ -37,7 +36,6 @@
import org.jnode.net.ipv4.config.IPv4ConfigurationService;
import org.jnode.net.syntax.IPv4AddressArgument;
import org.jnode.shell.AbstractCommand;
-import org.jnode.shell.CommandLine;
import org.jnode.shell.syntax.Argument;
import org.jnode.shell.syntax.DeviceArgument;
@@ -69,8 +67,8 @@
new IfconfigCommand().execute(args);
}
- public void execute(CommandLine commandLine, InputStream in, PrintStream out, PrintStream err)
- throws NameNotFoundException, ApiNotFoundException, NetworkException {
+ public void execute() throws NameNotFoundException, ApiNotFoundException, NetworkException {
+ PrintWriter out = getOutput().getPrintWriter();
if (!ARG_DEVICE.isSet()) {
// Print MAC address, MTU and IP address(es) for all network devices.
final DeviceManager dm = InitialNaming.lookup(DeviceManager.NAME);
Modified: trunk/net/src/net/org/jnode/net/command/NetstatCommand.java
===================================================================
--- trunk/net/src/net/org/jnode/net/command/NetstatCommand.java 2008-11-09 03:32:20 UTC (rev 4685)
+++ trunk/net/src/net/org/jnode/net/command/NetstatCommand.java 2008-11-09 08:08:19 UTC (rev 4686)
@@ -21,8 +21,7 @@
package org.jnode.net.command;
-import java.io.InputStream;
-import java.io.PrintStream;
+import java.io.PrintWriter;
import org.jnode.driver.net.NetworkException;
import org.jnode.net.NetworkLayer;
@@ -30,7 +29,6 @@
import org.jnode.net.TransportLayer;
import org.jnode.net.util.NetUtils;
import org.jnode.shell.AbstractCommand;
-import org.jnode.shell.CommandLine;
import org.jnode.util.Statistic;
import org.jnode.util.Statistics;
@@ -50,16 +48,15 @@
/**
* Execute this command
*/
- public void execute(CommandLine cmdLine, InputStream in, PrintStream out, PrintStream err)
- throws Exception {
+ public void execute() throws Exception {
final NetworkLayerManager nlm = NetUtils.getNLM();
for (NetworkLayer nl : nlm.getNetworkLayers()) {
- showStats(out, nl, 80);
+ showStats(getOutput().getPrintWriter(), nl, 80);
}
}
- private void showStats(PrintStream out, NetworkLayer nl, int maxWidth) throws NetworkException {
+ private void showStats(PrintWriter out, NetworkLayer nl, int maxWidth) throws NetworkException {
out.println(nl.getName() + ": ID " + nl.getProtocolID());
final String prefix = " ";
out.print(prefix);
@@ -73,7 +70,7 @@
out.println();
}
- private void showStats(PrintStream out, Statistics stat, int maxWidth, String prefix)
+ private void showStats(PrintWriter out, Statistics stat, int maxWidth, String prefix)
throws NetworkException {
final Statistic[] list = stat.getStatistics();
if (list.length == 0) {
Modified: trunk/net/src/net/org/jnode/net/command/PingCommand.java
===================================================================
--- trunk/net/src/net/org/jnode/net/command/PingCommand.java 2008-11-09 03:32:20 UTC (rev 4685)
+++ trunk/net/src/net/org/jnode/net/command/PingCommand.java 2008-11-09 08:08:19 UTC (rev 4686)
@@ -21,8 +21,7 @@
package org.jnode.net.command;
-import java.io.InputStream;
-import java.io.PrintStream;
+import java.io.PrintWriter;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.util.HashMap;
@@ -41,7 +40,6 @@
import org.jnode.net.ipv4.layer.IPv4NetworkLayer;
import org.jnode.net.util.NetUtils;
import org.jnode.shell.AbstractCommand;
-import org.jnode.shell.CommandLine;
import org.jnode.shell.syntax.Argument;
import org.jnode.shell.syntax.HostNameArgument;
@@ -73,14 +71,14 @@
new PingCommand().execute(args);
}
- public void execute(CommandLine commandLine, InputStream in, PrintStream out, PrintStream err)
- throws SocketException, InterruptedException {
+ public void execute() throws SocketException, InterruptedException {
try {
this.dst = new IPv4Address(ARG_HOST.getAsInetAddress());
} catch (UnknownHostException ex) {
- err.println("Unknown host: " + ex.getMessage());
+ getError().getPrintWriter().println("Unknown host: " + ex.getMessage());
exit(1);
}
+ final PrintWriter out = getOutput().getPrintWriter();
final IPv4Header netHeader =
new IPv4Header(0, this.ttl, IPv4Constants.IPPROTO_ICMP, this.dst, 8);
Modified: trunk/net/src/net/org/jnode/net/command/ResolverCommand.java
===================================================================
--- trunk/net/src/net/org/jnode/net/command/ResolverCommand.java 2008-11-09 03:32:20 UTC (rev 4685)
+++ trunk/net/src/net/org/jnode/net/command/ResolverCommand.java 2008-11-09 08:08:19 UTC (rev 4686)
@@ -21,8 +21,7 @@
package org.jnode.net.command;
-import java.io.InputStream;
-import java.io.PrintStream;
+import java.io.PrintWriter;
import java.util.Collection;
import org.jnode.driver.net.NetworkException;
@@ -30,7 +29,6 @@
import org.jnode.net.ipv4.util.ResolverImpl;
import org.jnode.net.syntax.IPv4AddressArgument;
import org.jnode.shell.AbstractCommand;
-import org.jnode.shell.CommandLine;
import org.jnode.shell.syntax.Argument;
import org.jnode.shell.syntax.FlagArgument;
@@ -59,9 +57,9 @@
new ResolverCommand().execute(args);
}
- public void execute(CommandLine commandLine, InputStream in, PrintStream out, PrintStream err)
- throws NetworkException {
+ public void execute() throws NetworkException {
IPv4Address server = ARG_DNS_SERVER.getValue();
+ PrintWriter out = getOutput().getPrintWriter();
if (FLAG_ADD.isSet()) {
// Add a DNS server
ResolverImpl.addDnsServer(server);
Modified: trunk/net/src/net/org/jnode/net/command/RouteCommand.java
===================================================================
--- trunk/net/src/net/org/jnode/net/command/RouteCommand.java 2008-11-09 03:32:20 UTC (rev 4685)
+++ trunk/net/src/net/org/jnode/net/command/RouteCommand.java 2008-11-09 08:08:19 UTC (rev 4686)
@@ -23,8 +23,7 @@
import static org.jnode.net.ethernet.EthernetConstants.ETH_P_IP;
-import java.io.InputStream;
-import java.io.PrintStream;
+import java.io.PrintWriter;
import javax.naming.NameNotFoundException;
@@ -39,7 +38,6 @@
import org.jnode.net.syntax.IPv4HostArgument;
import org.jnode.net.util.NetUtils;
import org.jnode.shell.AbstractCommand;
-import org.jnode.shell.CommandLine;
import org.jnode.shell.syntax.Argument;
import org.jnode.shell.syntax.DeviceArgument;
import org.jnode.shell.syntax.FlagArgument;
@@ -72,8 +70,7 @@
new RouteCommand().execute(args);
}
- public void execute(CommandLine commandLine, InputStream in, PrintStream out, PrintStream err)
- throws NoSuchProtocolException, NetworkException, NameNotFoundException {
+ public void execute() throws NoSuchProtocolException, NetworkException, NameNotFoundException {
final IPv4NetworkLayer ipNL =
(IPv4NetworkLayer) NetUtils.getNLM().getNetworkLayer(ETH_P_IP);
final IPv4Address target = ARG_TARGET.getValue();
@@ -86,6 +83,7 @@
} else if (FLAG_DEL.isSet()) {
cfg.deleteRoute(target, gateway, device);
} else {
+ PrintWriter out = getOutput().getPrintWriter();
out.println("Routing table");
out.println(ipNL.getRoutingTable());
}
Modified: trunk/net/src/net/org/jnode/net/command/RpcInfoCommand.java
===================================================================
--- trunk/net/src/net/org/jnode/net/command/RpcInfoCommand.java 2008-11-09 03:32:20 UTC (rev 4685)
+++ trunk/net/src/net/org/jnode/net/command/RpcInfoCommand.java 2008-11-09 08:08:19 UTC (rev 4686)
@@ -22,8 +22,7 @@
package org.jnode.net.command;
import java.io.IOException;
-import java.io.InputStream;
-import java.io.PrintStream;
+import java.io.PrintWriter;
import java.net.InetAddress;
import java.net.UnknownHostException;
@@ -32,7 +31,6 @@
import org.acplt.oncrpc.OncRpcProtocols;
import org.acplt.oncrpc.OncRpcServerIdent;
import org.jnode.shell.AbstractCommand;
-import org.jnode.shell.CommandLine;
import org.jnode.shell.syntax.Argument;
import org.jnode.shell.syntax.HostNameArgument;
@@ -57,9 +55,11 @@
new RpcInfoCommand().execute(args);
}
- public void execute(CommandLine commandLine, InputStream in, PrintStream out, PrintStream err) {
+ public void execute() {
OncRpcPortmapClient client = null;
String hostname = ARG_HOST.getValue();
+ PrintWriter out = getOutput().getPrintWriter();
+ PrintWriter err = getError().getPrintWriter();
try {
InetAddress host = InetAddress.getByName(hostname);
client = new OncRpcPortmapClient(host, OncRpcProtocols.ONCRPC_UDP);
Modified: trunk/net/src/net/org/jnode/net/command/TcpInoutCommand.java
===================================================================
--- trunk/net/src/net/org/jnode/net/command/TcpInoutCommand.java 2008-11-09 03:32:20 UTC (rev 4685)
+++ trunk/net/src/net/org/jnode/net/command/TcpInoutCommand.java 2008-11-09 08:08:19 UTC (rev 4686)
@@ -3,7 +3,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.io.PrintStream;
+import java.io.PrintWriter;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
@@ -12,7 +12,6 @@
import javax.net.SocketFactory;
import org.jnode.shell.AbstractCommand;
-import org.jnode.shell.CommandLine;
import org.jnode.shell.syntax.Argument;
import org.jnode.shell.syntax.HostNameArgument;
import org.jnode.shell.syntax.PortNumberArgument;
@@ -56,8 +55,7 @@
new TcpInoutCommand().execute(args);
}
- public void execute(CommandLine commandLine, InputStream in, PrintStream out, PrintStream err)
- throws IOException {
+ public void execute() throws IOException {
Socket socket;
if (ARG_LOCAL_PORT.isSet()) {
int port = ARG_LOCAL_PORT.getValue();
@@ -68,7 +66,9 @@
int port = ARG_PORT.getValue();
socket = SocketFactory.getDefault().createSocket(host, port);
}
-
+ InputStream in = getInput().getInputStream();
+ OutputStream out = getOutput().getOutputStream();
+ PrintWriter err = getError().getPrintWriter();
toThread = new CopyThread(in, socket.getOutputStream(), err);
fromThread = new CopyThread(socket.getInputStream(), out, err);
@@ -104,10 +104,10 @@
private class CopyThread extends Thread {
private final InputStream in;
private final OutputStream out;
- private final PrintStream err;
+ private final PrintWriter err;
private boolean terminated;
- CopyThread(InputStream in, OutputStream out, PrintStream err) {
+ CopyThread(InputStream in, OutputStream out, PrintWriter err) {
this.in = in;
this.out = out;
this.err = err;
Modified: trunk/net/src/net/org/jnode/net/command/TftpCommand.java
===================================================================
--- trunk/net/src/net/org/jnode/net/command/TftpCommand.java 2008-11-09 03:32:20 UTC (rev 4685)
+++ trunk/net/src/net/org/jnode/net/command/TftpCommand.java 2008-11-09 08:08:19 UTC (rev 4686)
@@ -22,12 +22,9 @@
package org.jnode.net.command;
import java.io.File;
-import java.io.InputStream;
-import java.io.PrintStream;
import org.jnode.net.ipv4.tftp.TFTPClient;
import org.jnode.shell.AbstractCommand;
-import org.jnode.shell.CommandLine;
import org.jnode.shell.syntax.Argument;
import org.jnode.shell.syntax.FileArgument;
import org.jnode.shell.syntax.FlagArgument;
@@ -62,9 +59,8 @@
new TftpCommand().execute(args);
}
- public void execute(CommandLine commandLine, InputStream in, PrintStream out, PrintStream err)
- throws Exception {
- TFTPClient client = new TFTPClient(out);
+ public void execute() throws Exception {
+ TFTPClient client = new TFTPClient(getOutput().getPrintWriter());
String host = ARG_SERVER.getValue();
File file = ARG_FILENAME.getValue();
if (FLAG_PUT.isSet()) {
@@ -89,7 +85,7 @@
exit(2);
}
}
- client.run(in);
+ client.run(getInput().getReader());
}
}
}
Modified: trunk/net/src/net/org/jnode/net/command/WLanCtlCommand.java
===================================================================
--- trunk/net/src/net/org/jnode/net/command/WLanCtlCommand.java 2008-11-09 03:32:20 UTC (rev 4685)
+++ trunk/net/src/net/org/jnode/net/command/WLanCtlCommand.java 2008-11-09 08:08:19 UTC (rev 4686)
@@ -21,15 +21,11 @@
package org.jnode.net.command;
-import java.io.InputStream;
-import java.io.PrintStream;
-
import org.jnode.driver.ApiNotFoundException;
import org.jnode.driver.Device;
import org.jnode.driver.net.NetworkException;
import org.jnode.driver.net.WirelessNetDeviceAPI;
import org.jnode.shell.AbstractCommand;
-import org.jnode.shell.CommandLine;
import org.jnode.shell.syntax.Argument;
import org.jnode.shell.syntax.DeviceArgument;
import org.jnode.shell.syntax.FlagArgument;
@@ -60,8 +56,7 @@
new WLanCtlCommand().execute(args);
}
- public void execute(CommandLine commandLine, InputStream in, PrintStream out, PrintStream err)
- throws ApiNotFoundException, NetworkException {
+ public void execute() throws ApiNotFoundException, NetworkException {
final Device dev = ARG_DEVICE.getValue();
final WirelessNetDeviceAPI api;
api = dev.getAPI(WirelessNetDeviceAPI.class);
@@ -69,7 +64,7 @@
// Perform the selected operation
if (FLAG_SET_ESSID.isSet()) {
final String essid = ARG_VALUE.getValue();
- out.println("Setting ESSID on " + dev.getId() + " to " + essid);
+ getOutput().getPrintWriter().println("Setting ESSID on " + dev.getId() + " to " + essid);
api.setESSID(essid);
}
}
Modified: trunk/net/src/net/org/jnode/net/command/WgetCommand.java
===================================================================
--- trunk/net/src/net/org/jnode/net/command/WgetCommand.java 2008-11-09 03:32:20 UTC (rev 4685)
+++ trunk/net/src/net/org/jnode/net/command/WgetCommand.java 2008-11-09 08:08:19 UTC (rev 4686)
@@ -20,27 +20,27 @@
*/
package org.jnode.net.command;
-import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.io.PrintStream;
+import java.io.PrintWriter;
import java.net.URL;
import org.jnode.shell.AbstractCommand;
-import org.jnode.shell.CommandLine;
import org.jnode.shell.syntax.Argument;
import org.jnode.shell.syntax.FlagArgument;
import org.jnode.shell.syntax.URLArgument;
public class WgetCommand extends AbstractCommand {
+ private static final int BUFFER_SIZE = 8192;
+
private final FlagArgument ARG_DEBUG =
new FlagArgument("debug", Argument.OPTIONAL, "if set, output debug information");
private final URLArgument ARG_SOURCE =
new URLArgument("url", Argument.MANDATORY + Argument.MULTIPLE, "the source URL(s)");
- private PrintStream out;
- private PrintStream err;
+ private PrintWriter out;
+ private PrintWriter err;
public WgetCommand() {
super("Fetch the contents of one or more URLs.");
@@ -52,10 +52,9 @@
}
@Override
- public void execute(CommandLine commandLine, InputStream in,
- PrintStream out, PrintStream err) throws Exception {
- this.out = out;
- this.err = err;
+ public void execute() throws Exception {
+ this.out = getOutput().getPrintWriter();
+ this.err = getError().getPrintWriter();
boolean debug = ARG_DEBUG.isSet();
int errorCount = 0;
for (URL url : ARG_SOURCE.getValues()) {
@@ -108,15 +107,15 @@
*/
protected void get(URL url, String localFileName) throws IOException {
InputStream is = null;
- BufferedOutputStream bos = null;
+ FileOutputStream os = null;
try {
is = url.openStream();
- bos = new BufferedOutputStream(new FileOutputStream(localFileName));
- byte[] buffer = new byte[8192];
+ os = new FileOutputStream(localFileName);
+ byte[] buffer = new byte[BUFFER_SIZE];
int numRead;
long numWritten = 0;
while ((numRead = is.read(buffer)) != -1) {
- bos.write(buffer, 0, numRead);
+ os.write(buffer, 0, numRead);
numWritten += numRead;
}
is.close();
@@ -124,8 +123,8 @@
if (is != null) {
is.close();
}
- if (bos != null) {
- bos.close();
+ if (os != null) {
+ os.close();
}
}
}
Modified: trunk/net/src/net/org/jnode/net/ipv4/tftp/TFTPClient.java
===================================================================
--- trunk/net/src/net/org/jnode/net/ipv4/tftp/TFTPClient.java 2008-11-09 03:32:20 UTC (rev 4685)
+++ trunk/net/src/net/org/jnode/net/ipv4/tftp/TFTPClient.java 2008-11-09 08:08:19 UTC (rev 4686)
@@ -25,9 +25,8 @@
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.io.Reader;
import java.net.InetAddress;
import java.net.UnknownHostException;
@@ -51,21 +50,21 @@
public static final String QUIT_CMD = "quit";
private BufferedReader br;
- private PrintStream out;
+ private PrintWriter out;
private InetAddress serverAddress;
private int mode = BINARY_MODE;
private boolean quit;
- public TFTPClient(PrintStream out) {
+ public TFTPClient(PrintWriter out) {
this.out = out;
}
@SuppressWarnings("deprecation")
- public void run(InputStream in) throws IOException {
+ public void run(Reader in) throws IOException {
// FIXME ... figure out to how to use JNode command argument parsing
// (and completion) for our little TFTP interactive command syntax.
- this.br = new BufferedReader(new InputStreamReader(in));
+ this.br = new BufferedReader(in);
out.println("JNode TFTP Client");
do {
out.print("tftp> ");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|