How to Save a File form a JAVA code into the CDrive

Hello, i need to create a file and save it in the Cdrive of my computer.
I could create the file and get the command prompt to ask me the file name to save it.
However, my problem is that the file is saved in the Cdrive with nothing inside! I can manage to save the file and give it a name, but i can't save the inside of it... the page comes blank...
if someone could help me and tell me why the inside isn't there and how to fix it, it could be very very helpfull!
thx
waiting for any reply
the part where i know i got it wrong is this:
// Save the File.txt in the Cdrive + MSG
               System.out.println( FILENAME_MSG ) ;
               BufferedReader br = new BufferedReader( new InputStreamReader ( System.in ),1 ) ;
               PeastBase = br.readLine() ;
               FileOutputStream fout = new FileOutputStream ( PeastBase ) ;
               OutputStreamWriter out = new OutputStreamWriter ( fout , "Shift_JIS" ) ;
               // Write in File
               out.write( CopyBase ) ;
               // Save PeastBase
               out.flush() ;
               // Close the Bufferedwriter
               out.close() ;
Anyway these are the complete code in case of need:
import java.io.*;
import java.util.ArrayList;
class Exp11 {
     public static void main(String[] args) throws IOException{
          try{
               File objCopyBaseFile = new File( "aaa" ) ;
               File objPeastBaseFile = new File( "bbb" ) ;
               //MAX Letters and Lines Input
               final int MAX_COLS = 10 ;
               final int MAX_ROWS = 10 ;
               final String START_MSG = "Input any LETTER" ;
               final String START_MSG1 = "10 LETTERS per Line, 10 LINES Max is Possible" ;
               final String START_MSG2 = "Input w will Save the FILE and FINISH" ;
               final String COUNT_STRING_ERROR = "Letters Input per Line is OVER" ;
               final String COUNT_ROW_ERROR = "Lines Number is OVER" ;
               final String FILENAME_MSG = "Input the File Name" ;
               String PeastBase ;
               String InputBase ;
               String cpBuffer ;
               String CopyBase ;
               int rownumber ;
               PeastBase = " " ;
               InputBase = "w" ;
               cpBuffer = " " ;
               CopyBase = " " ;
               rownumber = 0 ;
               FileOutputStream fos = new FileOutputStream( "fos.txt" ) ;
               OutputStreamWriter ow = new OutputStreamWriter( fos , "EUC-JP" ) ;
               BufferedWriter bw = new BufferedWriter( new FileWriter ( "out.txt", true )) ;
               // Start MSG
               System.out.println( START_MSG ) ;
               System.out.println( START_MSG1 ) ;
               System.out.println( START_MSG2 ) ;
               // Input
               ArrayList<String> array = new ArrayList<String>() ;
               int i ;
               i = 0 ;
               do {
                    BufferedReader br = new BufferedReader( new InputStreamReader ( System.in ),1 ) ;
                    PeastBase = br.readLine() ;
                    // Let's Count
                    if( !PeastBase.equals( InputBase) ){
                         rownumber ++ ;
                         // Check the Input letters
                         if ( countString(PeastBase,MAX_COLS )){
                              array.add(PeastBase) ;
                         else{
                              System.out.println( COUNT_STRING_ERROR ) ;
                         // Check the Lines
                         if ( countRow( rownumber,MAX_ROWS )){
                              array.add( PeastBase ) ;
                         else{
                              System.out.println( COUNT_ROW_ERROR ) ;
               } while ( !PeastBase.equals( InputBase ) ) ;
               // enter the data
               for( int      j=0;j<array.size();j++ ){
                    System.out.println( "How Many Time Input==>"+array.get(j) ) ;
               // Save the File.txt in the Cdrive + MSG
               System.out.println( FILENAME_MSG ) ;
               BufferedReader br = new BufferedReader( new InputStreamReader ( System.in ),1 ) ;
               PeastBase = br.readLine() ;
               FileOutputStream fout = new FileOutputStream ( PeastBase ) ;
               OutputStreamWriter out = new OutputStreamWriter ( fout , "Shift_JIS" ) ;
               // Write in File
               out.write( CopyBase ) ;
               // Save PeastBase
               out.flush() ;
               // Close the Bufferedwriter
               out.close() ;
          catch ( IOException e ){
               System.out.println( e ) ;
          finally{
     static boolean countString ( String bufString , int maxCount ) throws IOException{
          int StringCnt ;
          StringCnt = 0 ;
          // Count Letters per Lines
          StringCnt = bufString.length() ;
          if( maxCount>= StringCnt ){
               return true ;
          else{
               return false ;
     static boolean countRow ( int rownumber , int maxLine) throws IOException{
          int StringLine ;
          StringLine = 0 ;
          if( maxLine>= rownumber ){
               return true ;
          else{
               return false ;
PLEASE ANY HELP
THX

I'm not great with IO yet, but I see you use
out.write(CopyBase);But I only see you initialize CopyBase to equal an empty String.
So it should be writing nothing to the file.

Similar Messages

  • How to use .properties files in Webdynpro Java code?

    Hi all,
      I want to use a logon.properties file when I initial a JCO connection pool in my webdynpro DC (JCO.addClientPool()),but  I found when I deployed this DC to the server, it always giv e me an FileNotFoundException. So I donot know how to deploy a .properties file to the server and how to access this file in my Java code?
    Thans and Best regards
    Deyang

    Hi,
    1) put .properties file to your packege under src\packages folder (src\packages\com\sdn\properties\jco.properties)
    2) load property:
         final InputStream is = getClass().getClassLoader().getResourceAsStream("com/sdn/properties/jco.properties");
         final Properties properties = new Properties();
         try
              properties.load(is);
         catch(Exception e)
              wdComponentAPI.getMessageManager().reportException(new WDNonFatalException(e), false);
    Regatds Maxim R.

  • How to specify a file path in java code to run on Unix machine?

    Hi
    I have a problem when running my project Swing on Unix machine.
    In my code, the user will press a button and then the program will look for the file "ReadMe" in the folder "Documentation" , and reads the content of this file. My code is "Documentation\\ReadMe" and it works well on PC. (The folder "Documentation" is in the same directory with my Java code).
    But when I try on Unix, the program can not read the file. It can only read the file "ReadMe" if I take this file and put it in the same directory with my Java code ( this means not through another folder). So how can we make it read the file in a folder ? It seems that "Documentation\\ReadMe" does not work in Unix, or the symbol "\\" does not work.
    I would be thankful if anybody can help me with this.
    Thank you very much

    You really shouldn't use any path method, as neither are very consistant or platform independent. The JVM provides a way to grab resources from the classpath. These resources can be any data at all, in fact, it's how java itself locates classes. Here's an example how you would do this in a non-static method.
    public URL getReadMe() {
      // In this context the forward slash is universal
      String docDirectory = "Documentation/"
      // We have to use the classloader to grab the resource
      ClassLoader cl = this.getClass().getClassLoader();
      // Next we get the resource 
      URL readMeURL = cl.getResource(docDirectory + "ReadMe");
      return readMeURL;
    }The URL can be used in whatever way you need to get the information out of the resource. If it was an image you might use the "Toolkit" to make an image object out of it. The great thing about this method is it will work even if your loading the program out of a Jar file. The resource paths start at the top of the classpath, just like classes.

  • How to output a file showing visible time code from the source tape

    Can someone tell me which settings to use to output a file that has a visible time code readout from the source tape.  I shot an interview and now I want to make a video file for a transcriber so they can include the time code reference numbers from the source video on the written transcript.  Also, does the file need to be output from the timeline, or can this be done directly from a clip in the project.
    Thanks.
    Specs:
    PC with Windows Vista
    Premier Pro CS4

    Hi,
    You could try maybe selecting all your clips on the timeline and drag the "timecode" video effect onto it ( type the word timecode at the top of effect panel on left to find it fast )...
    Then you can change it from smpte if you want -----to source or media ...something like that...or to 'generate'...use what you like best..
    you can also change the codes position in the clip...
    Rod

  • How to save pdf file in database

    Dear All,
    my application is forms 6i and database is 8i,requirement is that how to save pdf file in database and users can view through forms

    I'll apologize up front for the length of this post. I have a few database procedures I created that write a file to a BLOB column in a table as well as retrieve the BLOB from the column after it stored there. I have successfully stored many different types of binary file to the database using these procedures - including PDF files. I have not used these procedures in a Form so I can confirm that they will work, but theoretically they should work. I'm including the code for each procedure in this posting - hence the apology for the long post! :-)
    Also, since these procedures reside on the database you will need to use Forms TEXT_IO built-in package to write your file to the server before you can use these procedures to store and retrieve the file from the database.
    These procedures reads and writes a binary file to a table called "LOB_TABLE." You will need to modify the procedure to write to your table.
    -- Author :  Craig J. Butts (CJB)
    -- Name   :  load_file_to_blob.sql
    --        :  This procedure uses an Oracle Directory called "IN_FILE_LOC".  If you
    --           already have a directory defined in the database or would prefer to use
    --           a different Directory name, make sure you modify line 21 to reflect the
    --           new Directory name.
    -- ==================================================================================
    -- History
    -- DATE        WHO         DESCRIPTION
    -- 12/11/07    CJB         Created.
    CREATE OR REPLACE PROCEDURE load_file_to_blob (p_filename IN VARCHAR2) IS
       out_blob    BLOB;
       in_file     BFILE;
       blob_length INTEGER;
       vErrMsg     VARCHAR2(2000);
    BEGIN
       -- set the in_file
       in_file := BFILENAME('IN_FILE_LOC',p_filename);
       -- Get the size of the file
       dbms_lob.fileopen(in_file, dbms_lob.file_readonly);
       blob_length := dbms_lob.getlength(in_file);
       dbms_lob.fileclose(in_file);
       -- Insert a new Record into the tabel containing the
       -- filename specified in P_FILENAME and a LOB_LOCATOR.
       -- Return the LOB_LOCATOR and assign it to out_blob.
       INSERT INTO lob_table (filename, blobdata)
          VALUES (p_filename, EMPTY_BLOB())
          RETURNING blobdata INTO out_blob;
       -- Load the file into the database as a blob.
       dbms_lob.open(in_file, dbms_lob.lob_readonly);
       dbms_lob.open(out_blob, dbms_lob.lob_readwrite);
       dbms_lob.loadfromfile(out_blob, in_file, blob_length);
       -- Close handles to blob and file
       dbms_lob.close(out_blob);
       dbms_lob.close(in_file);
       commit;
       -- Confirm insert by querying the database
       -- for Lob Length information and output results
       blob_length := 0;
       BEGIN
          SELECT dbms_lob.getlength(blobdata) into blob_length
            FROM lob_table
           WHERE filename = p_filename;
       EXCEPTION WHEN OTHERS THEN
          vErrMsg := 'No data Found';
       END;
       vErrMsg := 'Successfully inserted BLOB '''||p_filename||''' of size '||blob_length||' bytes.';
       dbms_output.put_line(vErrMsg);
    END;
    -- Author   :  Craig J. Butts (CJB)
    -- Name     :  write_blob_to_file.sql
    -- Descrip  :  This procedure takes a BLOB object from a database table and writes it
    --             to the file system
    -- ==================================================================================
    -- History
    -- DATE        WHO         DESCRIPTION
    -- 12/11/07    CJB         Created.
    CREATE OR REPLACE PROCEDURE write_blob_to_file ( p_filename IN VARCHAR2 ) IS
       v_blob      BLOB;
       blob_length INTEGER;
       out_file    UTL_FILE.FILE_TYPE;
       v_buffer    RAW(32767);
       chunk_size  BINARY_INTEGER := 32767;
       blob_position INTEGER := 1;
       vErrMsg     VARCHAR2(2000);
    BEGIN
       -- Retrieve the BLOB for reading
       BEGIN
          SELECT blobdata
            INTO v_blob
            FROM lob_table
           WHERE filename = p_filename;
       EXCEPTION WHEN OTHERS THEN
          vErrMsg := 'No data found';
       END;
       -- Retrieve the SIZE of the BLOB
       blob_length := DBMS_LOB.GETLENGTH(v_blob);
       -- Open a handle to the location where you are going to write the blob
       -- Note:  The 'WB' parameter means "Write in Byte Mode" and is only
       --          available in the UTL_FILE pkg with Oracle 10g or later.
       --        USE 'W' instead for pre Oracle 10q databases.
       out_file := UTL_FILE.FOPEN('OUT_FILE_LOC',p_filename, 'wb', chunk_size);
       -- Write the BLOB to the file in chunks
       WHILE blob_position <= blob_length LOOP
          IF ( ( blob_position + chunk_size - 1 ) > blob_length ) THEN
             chunk_size := blob_length - blob_position + 1;
          END IF;
          dbms_lob.read(v_blob, chunk_size, blob_position, v_buffer );
          UTL_FILE.put_raw ( out_file, v_buffer, TRUE);
          blob_position := blob_position + chunk_size;     
       END LOOP;  
    END;Hope this helps.
    Craig...
    -- If my response or the response of another is helpful or answers your question please mark the response accordingly. Thanks!

  • How to save image files into SQL Server?

    Hello, All:
    Does anyone know how to save image files into SQL Server? Does the file type have to be changed first?? Please help me! Thank you!

    You need a BLOB field (usually)... Then you can check this tutorial out:
    http://java.sun.com/developer/onlineTraining/Database/JDBC20Intro/exercises/BLOBPut/
    There are other exercises on that site, including one on reading the images back.

  • Could u plz help me to find simple example for how to save data file in a spread sheet or any other way in the real time controller for Sbrio 9642 using memory or usb flash memory

    Could u plz help me to find simple example for how to save data file in a spread sheet or any other way in the real time controller for Sbrio 9642 using memory or usb flash memory

    Here are a few Links to a helpful Knowledge Base article and a White Paper that should help you out: http://digital.ni.com/public.nsf/allkb/BBCAD1AB08F1B6BB8625741F0082C2AF and http://www.ni.com/white-paper/10435/en/ . The methods for File IO in Real Time are the same for all of the Real Time Targets. The White Paper has best practices for the File IO and goes over how to do it. 
    Alex D
    Applications Engineer
    National Instruments

  • How to save CSV file in application server while making infospoke

    How to save CSV file in application server to be used as destination while making infospoke.
    Please give the steps.........

    Hi
    If you want to load your flatfile from Application server,then you need to trasfer your file from your desktop(Computer) to Application server by using FTP.
    Try using ARCHIVFILE_CLIENT_TO_SERVER Function module.
    You Just need to give thesource path and the target path
    goto SE37 t-code , which is Function module screen, give the function name ARCHIVFILE_CLIENT_TO_SERVER, on click F8 Execute button.
    for path variable give the file path where it resides like C:\users\xxx\desktop\test.csv
    for target path give the directory path on Application server: /data/bi_data
    remember the directory in Server starts with /.
    U have to where to place the file.
    Otherwise use 3rd party tools to connect to ur appl server like : Core FTP and Absolute FTP in google.
    Otherwise...
    Goto the T.code AL11. From there, you can find the directories available in the Application Server.
    For example, if you wanna save the file in the directory "DIR_HOME", then you can find the path of the directories in the nearby column. With the help of this, you can specify the target path. Specify the target path with directory name followed by the filename with .CSV extension.
    Hope this helps
    regards
    gaurav

  • Does anyone know how to save a file in CC 10.0 or higher that is viewable in CC 9.2?

    I am trying to make my fiels viewable to someone who has Adobe CC version 9.2, but I have version 10.0. Does anyone know how to save my files so the are readable?

    You will likely get better program help in a program forum
    The Cloud forum is not about using individual programs
    The Cloud forum is about the Cloud as a delivery & install process
    If you will start at the Forums Index https://forums.adobe.com/welcome
    You will be able to select a forum for the specific Adobe product(s) you use
    Click the "down arrow" symbol on the right (where it says All communities) to open the drop down list and scroll

  • How to save iPhoto file in a separate portable hard disk drive?

    How to save iPhoto file in a separate portable hard disk drive?

    You want to move the iPhoto Library?
    Make sure the drive is formatted Mac OS Extended (Journaled)
    1. Quit iPhoto
    2. Copy the iPhoto Library from your Pictures Folder to the External Disk.
    3. Hold down the option (or alt) key while launching iPhoto. From the resulting menu select 'Choose Library' and navigate to the new location. From that point on this will be the default location of your library.
    4. Test the library and when you're sure all is well, trash the one on your internal HD to free up space.
    Regards
    TD

  • How to save Numbers file as Excel (XLSX) file ?

    I just want to know how to save Numbers files into Excel format. Because other than Mac users can't able to access Numbers format.

    File, Export To, Excel…

  • How to save psd files...

    how to save psd files so other can change (with all fonts and Layers)
    I need to know how to save everything in the psd so others still can use it.??

    Hi,
    If you have photoshop and you are working on it and have used layers , fonts , and other things
    Then after completing your work, click save and it will open save Box,
    make sure the file format in the box should be PSD and then you may save the file and then you can share with any one.
    Any one who has Photoshop will be able to open that file and can edit the layers and fonts..
    --Baljeet

  • How to save a pdf form with a button on Android?

    Hello can anyone inform me with the knowledge of how to save a pdf form after filling with button on an Android device?
    What code behind the button is necessary to make this work.

    It happens automatically. You don't need any code to trigger it.

  • How to save .pdf file using office word and excel

    Can someone help me how to save .pdf files using office word and excel?  I reinstalled my adobe 7.0 pro in my new pc and before I was able to do it but with my old pc.

    For anything after Office 2003, you have to print to the Adobe PDF printer. If you installed AA 7 on OS newer than XP, you may have to do a workaround to get it to work. With later versions of WORD you can always use the MS plugin for creating PDFs.

  • How do i transfer files form iphone to pc (windows)

    how do i transfer files form iphone to pc (windows)

    That depends on what kind of files you're talking about.
    If you mean photos, then you can just plug the phone in and it will appear like any other camera, mounting the camera roll like a flash drive or SD card.

Maybe you are looking for