Results 1 to 2 of 2

Thread:

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    wenzdy's Avatar
    Join Date: May:2004
    Location: .;-)
    Posts: 86

    . , Java. , , , , .
    :
    , ( Run ), -, bsplayer, . , txt , , , - .
    txt, - , .
    , , - , .


    , , system32, .


    import java.io.*;
    public class CmdExec {

    public static void main(String argv[]) {
    try {
    String line;
    Process p = Runtime.getRuntime().exec
    (System.getenv("windir") +"\\system32\\"+"tree.com /A");
    BufferedReader input =
    new BufferedReader
    (new InputStreamReader(p.getInputStream()));
    while ((line = input.readLine()) != null) {
    System.out.println(line);
    }
    input.close();
    }
    catch (Exception err) {
    err.printStackTrace();
    }
    }
    }





    , .


    import java.util.*;

    public class Now {

    public static void main(String arg[]) {
    /*
    ** Calendar cal = Calendar.getInstance(TimeZone.getTimeZon e("EST"));
    */
    Calendar cal = Calendar.getInstance(TimeZone.getDefault ());

    String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
    java.text.SimpleDateFormat sdf =
    new java.text.SimpleDateFormat(DATE_FORMAT);

    sdf.setTimeZone(TimeZone.getDefault());

    System.out.println("Now : " + sdf.format(cal.getTime()));
    }
    }




    txt .

    import java.io.*;

    class FileOutputDemo
    {

    public static void main(String args[])
    {
    FileOutputStream out; // declare a file output object
    PrintStream p; // declare a print stream object

    try
    {
    // Create a new file output stream
    // connected to "myfile.txt"
    out = new FileOutputStream("myfile.txt");

    // Connect print stream to the output stream
    p = new PrintStream( out );

    p.println (filename + " " + getDateTime());
    p.close();
    }
    catch (Exception e)
    {
    System.err.println ("Error writing to file");
    }
    }

    }




    import java.io.*;

    class FileInputDemo
    {
    public static void main(String args[])
    {
    // args.length is equivalent to argc in C
    if (args.length == 1)
    {
    try
    {
    // Open the file that is the first
    // command line parameter
    FileInputStream fstream = new
    FileInputStream(args[0]);

    // Convert our input stream to a
    // DataInputStream
    DataInputStream in =
    new DataInputStream(fstream);

    // Continue to read lines while
    // there are still some left to read
    while (in.available() !=0)
    {
    // Print file line to screen
    System.out.println (in.readLine());
    }

    in.close();
    }
    catch (Exception e)
    {
    System.err.println("File input error");
    }
    }
    else
    System.out.println("Invalid parameters");
    }

    }


    . . .

    , .
    Last edited by wenzdy; 15th November 2006 at 20:32.
    : Destiny flying high above all. Destiny can't replace my life scary shadows of my past are alive. Destiny who cares as it turns around and I know that it descends with a smile.

  2. #2
    ****** koshera's Avatar
    Join Date: Sep:2003
    Location: Sammamish, WA, USA
    Posts: 1,507
    , main , " " .CmdExec main , .
    usera String username = System.getProperty("user.name");
    Thre are 10 kinds of people in this world - people who know binary, and those who don't.
    -, .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Copyright © 1999-2011 . .
iskamPC.com | mobility.BG | Bloody's Techblog | | 3D Vision Blog |