首先,我试图理解outputStream,我正在阅读Merlin的“JavaNetworkPrograming2NS版”一书。书中有一个示例程序,我试图运行它并得到它的输出,但是没有输出。我理解它,但无法识别问题。
这是代码
import java.io.*;
public class SimpleOut
{
public static void main(String[] args) throws IOException
{
for (int i=0; i<args.length; i++)
{
println (args[i]);
}
}
public static void println(String msg) throws IOException
{
synchronized (System.out)
{
for (int i=0 ; i<msg.length(); i++)
System.out.write(msg.charAt (i) & 0xff);
System.out.write('\n');
}
System.out.flush();
}
}发布于 2014-02-22 17:28:36
在运行程序时,您似乎没有传递任何命令行参数。
当应用程序启动时,运行时系统通过String数组将命令行参数传递给应用程序的main方法。
示例:用户应输入
java NameOfFile arg1 arg2 arg3https://stackoverflow.com/questions/21957681
复制相似问题