• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to take the command line parameters  RSS feed

 
Bill Thompson
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Everyone,

I am struggling to take the Unicode command line parameters in java. Can anybody let me know how to do that.

Following is the java program that I have written:

import java.io.*;
import java.util.*;

public class CMDParam
{
public static void main(String args[])
{
File file = new File(args[0]);
if(file.exists())
{
if(file.isFile())
{
System.out.println(" " +args[0]+" IS A FILE");
}
else if(file.isDirectory())
{
System.out.println(""+args[0]+" is a directory.");
}
}
else
{
System.out.println("FILE DOES NOT EXIST");
}
}
}

Ran the program by giving the following command line arguements

java -Dfile.encoding="UTF-8" CMDParam 用状況使用
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bill Thompson:
Ran the program by giving the following command line arguements

java -Dfile.encoding="UTF-8" CMDParam 用状況使用


And what happened ?
 
Rene Larsen
Ranch Hand
Posts: 1179
Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't create a file just by calling. You can create a File object on an existent file.

To create a new file you can e.g. call
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's not what Bill is trying to do. He wants to check if a parameter is a file or a folder, or neither. There is no need whatsoever for creating files.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!