相关疑难解决方法(0)

如何从Windows上的命令行运行Java程序?

我正在尝试从Windows中的命令行执行Java程序.这是我的代码:

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class CopyFile
{
    public static void main(String[] args)
    {

        InputStream inStream = null;
        OutputStream outStream = null;

        try
        {

            File afile = new File("input.txt");
            File bfile = new File("inputCopy.txt");

            inStream = new FileInputStream(afile);
            outStream = new FileOutputStream(bfile);

            byte[] buffer = new byte[1024];

            int length;
            // copy the file content in bytes
            while ((length = inStream.read(buffer)) > 0)
            {

                outStream.write(buffer, 0, length);

            }

            inStream.close();
            outStream.close();

            System.out.println("File is …
Run Code Online (Sandbox Code Playgroud)

java

211
推荐指数
8
解决办法
124万
查看次数

System.out.printIn()错误?

我是Java编程的新手(并不擅长这个),我只是想编译这个小程序,所以我可以用它来做一个继承和多态问题.我正在使用JGrasp并且它一直告诉我System.out.printIn()有一些我做错了.我需要导入一些东西吗?这就是我所拥有的:

public class Book   
{
private String title;

private int pages;
public Book(String title, int pages)
{
this.title = new String(title);
setPages(pages);
}
public void setPages(int pages)
{
this.pages = pages;    
}
public int getPages()
{
return pages;           //superclass method   
}
public void print()
{
System.out.printIn(title + " has " + pages + " pages");
}
}
Run Code Online (Sandbox Code Playgroud)

我得到的输出是:

Book.java:33: error: cannot find symbol
  System.out.printIn(title + " has " + pages + " pages");

            ^

symbol:   method printIn(String)
location: variable out …
Run Code Online (Sandbox Code Playgroud)

java

-1
推荐指数
1
解决办法
1933
查看次数

标签 统计

java ×2