Results 1 to 2 of 2
Hybrid View
-
15th November 2006 19:50 #1
. , 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.
-
17th November 2006 14:54 #2
, 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.
-, .




Reply With Quote
Lenovo ThinkPad 15 IdeaPad 15
5th May 2023, 22:16 in