aspose file tools*
The moose likes Java in General and the fly likes Help, this file writer... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Help, this file writer..." Watch "Help, this file writer..." New topic
Author

Help, this file writer...

Robert Cooper
Greenhorn

Joined: May 12, 2003
Posts: 4
Question: Whay doesent this work?

// OutputUI.java
/**
*
* class OutputUI is a command line UI for Expr.
*
*
* @version 1.00 2003-05-16
* @author Robert & Linda Cooper (<rcooper567, lcooper264>
*
*/
public class OutputUI
{
/**
*
* main method calls to ConsoleIO to prompt user for input
* input is sent to Expr class parse method and returned from
* Expr class calc method.
*
*/

public static void main(java.lang.String[] args)
{
System.out.println( "======================================" );
System.out.println( "=== Begin of OutputUI ===" );
System.out.println( "======================================" );
System.out.println( " " );
String line, result;

Output outputObj = new Output();
line = ConsoleIO.getLine( "Enter line " );
while ( !line.equals( "" ) )
{
outputObj.open( line );
result = outputObj.write( line );
System.out.println( result );
System.out.println( "" );
line = ConsoleIO.getLine( "Enter pre: " );
}
outputObj.close();
System.out.println( " " );
System.out.println( "======================================" );
System.out.println( "=== End of OutputUI ===" );
System.out.println( "======================================" );
}//end main

}//end OutputUI
//Output.java
import java.io.*;
public class Output
{
public static void main(java.lang.String[] args)
{
System.out.println("program started");
}
private PrintWriter outFile;
public void open(String line)
{
try
{
FileOutputStream fos = new FileOutputStream( "seq.txt" );
PrintWriter outFile = new PrintWriter( fos, true );
write( line);
}
catch (Exception e){System.out.println("file not opened");}
}
public String write(String line)
{
try
{
outFile.write(line);
}
catch(Exception e){System.out.println("file not writen");}
return line;
}
public void close()
{
try
{
outFile.flush();
outFile.close();
}
catch(Exception e){System.out.println("file not closed");}
}
}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help, this file writer...