import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Example {
public static void main(String args[]) {
String s = null;
String cmd = "ls > /home/main/output/f.txt";
try {
Process p = Runtime.getRuntime().exec(cmd);
int i = p.waitFor();
if (i == 0){
BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
while ((s = stdInput.readLine()) != null) {
System.out.println(s);
}
}
else {
BufferedReader stdErr = new BufferedReader(new InputStreamReader(p.getErrorStream()));
// read the output from the command
while ((s = stdErr.readLine()) != null) {
System.out.println(s);
}
}
while executing ls > /home/main/output/f.txt from terminal in linux its creating f.txt.But cant run from java program ls: cannot access >: No such file or directory error is displayed .No f.txt is created.
Related Tutorials/Questions & Answers:
ls: cannot access >: No such file or directory:
cannot access >: No such
file or
directory error is displayed .No f.txt...ls:
cannot access >: No such
file or directory import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Example
Advertisements
Random Access File classRandom
Access File class Write a short note on Random
Access File class.
Please visit the following link:
Java Random
Access File RANDOM ACCESS FILE CONCEPTRANDOM
ACCESS FILE CONCEPT In a random
access file, first write the alphabets a,b, c, d till z. Read the
file
in reverse order and print it on screen
RANDOM ACCESS FILE CONCEPTRANDOM
ACCESS FILE CONCEPT Write a program that stores the names of four employees in an array of strings.
Store the contents of the array in an alphabetical order in a
file and display it back on
console. Do not use
RANDOM ACCESS FILE CONCEPTRANDOM
ACCESS FILE CONCEPT Write a program to use a
File object and print even numbers from two to ten.
Then using RandomAccessFile write numbers from 1 to 5. Then using seek () print
only the last 3 digits
RANDOM ACCESS FILE CONCEPTRANDOM
ACCESS FILE CONCEPT Write a program to write the details of an employee to a
file. Details such as year of
joining, department code, employee name and salary should be included. You must use
RandomAccessFile
Upload file to MS AccessUpload
file to MS Access Iam beginner and need to upload
file to msaccess using jsp . Iam using netbeans platform.
Kindly explain do I need to mention Attachment format in the table
File Directory MergingFile Directory Merging Two directories are given. Both contain a large amount of files. Each of the
directory can be more than a GB. We need to form a new
directory in which all the files from both the directories
creating a file in a directorycreating a
file in a directory hi i have tried all the
file methods to create a
file inside a
directory but none of them r working
some of them are
new
File ( ".", "C:/fileInRoot.txt" )
new
File ( "myDir", "/otherDir" )
File How to move a file from a directory to other directoryHow to move a
file from a
directory to other directory I tried the above example it will move the folder to other
directory but it does not move the image
file or other
file to a specified
directory. Can anyone help me?
Thanks
Traversing a file and directory under a directory then make an object of
File class and pass any
directory and filename to its constructor. After that, check it whether the
file or
directory you have entered is a
directory or a
file. If it is a
directory then it will display
Java - Deleting the file or Directory of
file and
directory pathnames. ADS_TO_REPLACE_1
Explanation...() which deletes the specified
directory or
file.
deletefile(String
file)ADS...()
Deletes the
file or
directory denoted by this abstract pathname
Checking if a file or directory existChecking if a
file or
directory exist
In this section you will learn how to check whether a
file or a
directory exist
or not. The " java.io "... will
return "true" if
file or
directory exist otherwise it returns
"
Delete file or Directory
Delete
file or
Directory
... or a
directory by using a java program. We pass the
file name or the
directory name to which... that contains the
file or
directory name to be deleted. Then we
check for
file whether
Copy Directory or File in Java will see how contains of a
directory or a
file is copied from... then
the program gives the output message like :
File or
directory does not exist... to the destination
directory otherwise the specified
name is copies (treated) as a
file name
Java - Deleting the file or Directory
Java - Deleting the
file or
Directory
... the specified
file or
directory after checking weather the
file exists or not. This topic... representation of
file and
directory pathnames. ADS_TO_REPLACE_1
Explanation
Creating a File in the directory.Creating a
file using HTML form action
In this example, you will learn to make a query form asking to to create a
file in PHP. You will have to write... of PHP code in the form.ADS_TO_REPLACE_1
for creating a
file in PHP, first
Determining if a File or Directory exist Determining if a
File or
Directory Exist
... to determine whether a
file or
directory exists or not.
If it exists it ... whether the
file or
directory denoted by this pathname
exists or not.
Here
Rename the File or Directory in Java Rename the
File or
Directory in Java
... that how a
file or
directory is renamed. This program illustrates you
the procedure... or
directory. If you mention
the
directory (path) with the new
file or
directory Java file get parent directoryJava
file get parent
directory
In this section, you will learn how to get the parent
directory of the
file.
Description of code:
The package java.io.... which of String type. This method returns the parent
directory of specified
file File copy from one directory to another in javaFile copy from one
directory to another in java I am trying to find very good code example for copying a
file from one
directory to another
directory in Java.
I have to write a program in my application for copying one
file Access Excel file through JDBCAccess Excel
file through JDBC
In this section, you will learn how to
access excel
file through Jdbc and
display records in JTable. As you know Excel comes... and the excel
file. Here the
name of the worksheet is equivalent to any database
How to load file from the directory in J2ME?How to load
file from the
directory in J2ME? Video player J2ME.
I have a folder name "music". I want to display all
file with extension is "*.mpg" on the List.
How can I do it, plz help me
Error: /usr/sbin/ifconfig: No such file or directoryError: /usr/sbin/ifconfig: No such
file or directory HI,
I am trying to run the some setup and it throws the error: Error: /usr/sbin/ifconfig: No such
file or
directory
How to solve this?
Thanks
HI,
this error
Using a Random Access File in Java RandAccessFile
Enter
File name : Filterfile.txt
Write... the characters from a
file using the readByte(
) method...;= in.readLine();
File file = new
File(str
URL file Download and Save in the Local DirectoryURL
file Download and Save in the Local
Directory
... and save this Url
File in the
specified
directory. This program specifies... and FileOutputStream write the data to the local
file in a specified
directory.
How and Where we Access struts Properties file - StrutsHow and Where we
Access struts Properties
file Hi Friends, am new to struts.I read that " you can store variables in xml
file(properties
file) and for future enhancements we just call properties
file . Now i want to implement
access access This is Nitha Sriram
i am having a problem that, i am having a combo box in the JSP page when i select an item from that i
am calling the onchange function.
In javascript i am getting the value now i want to pass
Java file new directory Java
file new
directory
In this section, you will learn how to create a new
directory.
Description of code:
This is a common task. The java.io.package... have created an object of
File class and
specify a
directory which you want