이 코드로 나를 도와주세요, java.lang.nullpointerexception plz 런타임 오류 예외가 발생했습니다.이 문제를 해결하고 데스크탑에서 Java 프로그램을 사용하여 모든 파일에 액세스하는 방법을 알려주십시오. , 나는 바탕 화면이나 다른 folde에서 어떤 이미지 나 텍스트 파일에 액세스하고 싶은데 어떤 코드를 써야 하나? .FYI 나는 멍청하다. 동일의 당신은 초기화하지 않고 i
을 비교하는프로그램을 실행하는 동안
import java.io.*;
class jarvis
{
public static void main(String args[])
{
String i=null,j=null,k=null,l=null,m=null,n=null,o=null,a=null,q=null;
try
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Command me: ");
if(i.equals("jarvis you there?"))
{
i=br.readLine();
System.out.println("at your service sir");
}
System.out.println("Command me: ");
if(j.equals("run command prompt"))
{
j=br.readLine();
Runtime r=Runtime.getRuntime();
Process p=r.exec("cmd.exe /c start");
}
System.out.println("Command me: ");
if(k.equals("run notepad"))
{
k=br.readLine();
Runtime r=Runtime.getRuntime();
Process p=r.exec("notepd.exe");
}
System.out.println("Command me: ");
if(l.equals("run paint"))
{
l=br.readLine();
Runtime r=Runtime.getRuntime();
Process p=r.exec("mspaint.exe");
}
System.out.println("Command me: ");
if(m.equals("open facebook"))
{
m=br.readLine();
Runtime r=Runtime.getRuntime();
Process p=r.exec("cmd.exe /c start www.facebook.com");
}
System.out.println("Command me: ");
if(n.equals("open google"))
{
n=br.readLine();
Runtime r=Runtime.getRuntime();
Process p=r.exec("cmd.exe /c start www.google.com");
}
System.out.println("Command me: ");
if(o.equals("open youtube"))
{
o=br.readLine();
Runtime r=Runtime.getRuntime();
Process p=r.exec("cmd.exe /c start www.youtube.com");
}
System.out.println("Command me: ");
if(a.equals("open yahoo"))
{
a=br.readLine();
Runtime r=Runtime.getRuntime();
Process p=r.exec("cmd.exe /c start www.yahoo.com");
}
System.out.println("Command me: ");
if(q.equals("open omegle"))
{
q=br.readLine();
Runtime r=Runtime.getRuntime();
Process p=r.exec("cmd.exe /c start www.omegle.com");
}
}
catch(Exception e)
{
System.out.print(e);
}
}
}