Write a file with specific path

hi all,
i found some sample code to write into a file, like using new FileOutputStream or new FileWriter.
the problem is that you only specify the file name. i'd like to specify the path where the file will be. is it possible ? which class should i use ?
regards

Hi,
File f = new File("C:\\Programs\\MyProgs\\Test.txt");
that should do.
Phil

Similar Messages

  • Writing a report file with specific information

    Hi, all:
    I need to write a text file with specific information in it. I'm going to copy it into Excel, so the easier the format, the better (perhaps CSV format?). I've never done this before, so here's the method I need to capture the information from:
         public void step() {
              greenColorStorage = new ArrayList();
              magentaColorStorage = new ArrayList();
              System.out.println( "==> Model step " + getTickCount() );// Checking step #
              for (int i = 0; i < soldierList.size (); i++) {
                   Soldier s = (Soldier) soldierList.get (i);
                   s.step();
              Collections.shuffle(soldierList);
              System.out.println("Shuffling collection now.");
              dsurf.updateDisplay ();
              System.out.println("Model.step() finished.");
              for (int i = 0; i < soldierList.size (); i++) {
                   Soldier s = (Soldier) soldierList.get (i);
                   if (s.getMyColor() == Color.green ) {
                        greenColorStorage.add(s);
                   if (s.getMyColor() == Color.magenta ) {
                        magentaColorStorage.add(s);
              if (magentaColorStorage.size() == 0 || greenColorStorage.size() == 0 ) {
                   stop();
         }In this method, I need to capture this information: There are soldiers on the Green team and on the Magenta team. I need to know how many there are originally, how many in this time step, at what time step the model stops, and how many of the winning color team are left when the model stops. How do I do this? If you can point me to a specific thread that shows how to write a report file like this, I'd be grateful, since I couldn't find one when I searched. Otherwise, I'd be grateful for examples. I'm in the middle of doing some research, and I have the feeling that I'll need to write report files in the future, so if you'd explain any code you provide, I would be quite grateful--I need to understand what I'm doing as well as simply using your code so that I can really learn what I'm doing when I do this again. Thanks very much!

    FileOutputStream
    public FileOutputStream(File file,
                            boolean append)
                     throws FileNotFoundException
    Creates a file output stream to write to the file represented by the specified File object.
    If the second argument is true, then bytes will be written to the end of the file
    rather than the beginning.
    */

  • Upload a file in Specific Path

    Hi All,
    I am not able to understand how to upload a file in specific path(Ex: D:\Upload). I am searched in many sites, but i didn't found any solution. By default it is taking C:\fakepath. Please help me how to give a default specific path while uploading a file .
    Thanks,
    Kushi

    Hi Ronald,
    Please find the attached screen shot here, in the screen shot you can find the path "C:\fakepath\io.txt". Here i am using io.txt file to upload. I want this file has to be place in other path i.e., "D:\upload". But by default the file is uploading in C:\fakepath. Plesae let me know where i need do changes.
    Here are the types i used:
    Attributes
    Type
    FILE_NAME
    STRING
    FILE_TYPE
    STRING
    FILE_SIZE
    STRING
    FILE_CONTENTS
    XSTRING
    Node2: N_FILE_DOWNLOAD 
    Cardinality is 0.n
    Attributes
    Type
    FILE_NAME
    STRING
    FILE_TYPE
    STRING
    FILE_SIZE
    STRING
    FILE_CONTENTS
    XSTRING

  • How to create PDF from text file with specific layout?

    I wanted to create the pdf from text file in specific layout - Landscape orientation and JIS B3 Page size while at Adobe Acrobat Pro.
    In past, I could do a right click on a text file (desktop area) and select print to print out the document into .pdf BUT only if I set the Adobe PDF to Landscape and JIS B3 Page size BEFORE.  And I could only do 15 text documents at once.
    I wanted to see if I could do the create the pdf from text file with specific layout in Adobe Acrobat without having to go to Control Panel to preset the Adobe PDF to specific layout at every time.   I would have to set Adobe PDF back to normal layout after I'm done with these pdf print outs.  I do lots of pdfs in normal layout.  Sometimes I would forget to do that.
    So, How do I do that?

    No such luck.  It would output the contents in letter size even in JIS B3 Page layout at MS word. 
    Is there a script or action where I could set the orientation and page size before creating PDF on these text files?

  • OSB file Write, not naming the file with specific name.

    Hi ALL,
    I have a requirement, i should accept the data or XML file from from JMs queue and place it in a location specified. For this i have build the PS and BS.
    Where PS will De-queue the JMS queue and route using Service call out to BS. And the BS will place the file in location. I could do this easily. BUT the thing is that i could not name the file perfectly with the intended file name. to build the BS i used .JCA file , .WSDL file, XML file from Jdeveloper. and imported to osb console. i could write the file as follows..
    MY business Services:
    services TYPE : ANY XML services
    transport
    Protocol ==> file
    Load Balancing Algorithm ==> round-robin
    Endpoint URI ==> file:///oracle/Middleware/user_projects/domains/Agile
    Request encoding ==> utf-8
    this is the file name i am getting:
    <con:metadata      xmlns:con="http://www.bea.com/wli/sb/test/config">
         <tran:response-code      xmlns:tran="http://www.bea.com/wli/sb/transports">0</tran:response-code>
         <tran:encoding      xmlns:tran="http://www.bea.com/wli/sb/transports">utf-8</tran:encoding>
         <file:filePath      xmlns:file="http://www.bea.com/wli/sb/transports/file">
         /oracle/Middleware/user_projects/domains/Agile/POTest3338620552690675292--411054fa.1363686ca89.3e8d.xml
         </file:filePath>
    </con:metadata>
    the file NAME : POTest3338620552690675292--411054fa.1363686ca89.3e8d.xml ( POTest is prefix and .xml is Sufix)
    3338620552690675292--411054fa.1363686ca89.3e8d i dont know y the this garbage file name is created...
    please give suggestions to avoid garbage name
    thanks --
    ANIL

    Hi ALL,
    I have a requirement, i should accept the data or XML file from from JMs queue and place it in a location specified. For this i have build the PS and BS.
    Where PS will De-queue the JMS queue and route using Service call out to BS. And the BS will place the file in location. I could do this easily. BUT the thing is that i could not name the file perfectly with the intended file name. to build the BS i used .JCA file , .WSDL file, XML file from Jdeveloper. and imported to osb console. i could write the file as follows..
    MY proxy services:
    services type : any XML services
    protocol :jms
    MY business Services:
    services TYPE : ANY XML services
    transport
    Protocol ==> file
    Load Balancing Algorithm ==> round-robin
    Endpoint URI ==> file:///oracle/Middleware/user_projects/domains/Agile
    Request encoding ==> utf-8
    this is the file name i am getting:
    <con:metadata xmlns:con="http://www.bea.com/wli/sb/test/config">
    <tran:response-code xmlns:tran="http://www.bea.com/wli/sb/transports">0</tran:response-code>
    <tran:encoding xmlns:tran="http://www.bea.com/wli/sb/transports">utf-8</tran:encoding>
    <file:filePath xmlns:file="http://www.bea.com/wli/sb/transports/file">
    /oracle/Middleware/user_projects/domains/Agile/POTest3338620552690675292--411054fa.1363686ca89.3e8d.xml
    </file:filePath>
    </con:metadata>
    the file NAME : POTest3338620552690675292--411054fa.1363686ca89.3e8d.xml ( POTest is prefix and .xml is Sufix)
    3338620552690675292--411054fa.1363686ca89.3e8d i dont know y the this garbage file name is created...
    i am getting this error when i process test from proxy services then i may use route and change it as Use Routing Options on the Service Callout and override the header (jca.file.FileName).
    but the thing is when i test from Business services also i am getting the same garbage name on both window and linux.
    please give suggestions to avoid garbage name
    thanks --
    ANIL

  • Open vi file with specific Labview version using batch file (Windows)

    I want to open certain vi with using Windows batch file and to use specific version of Labview development system. I tried
    "C:\Program Files (x86)\National Instruments\LabVIEW 2012\LabVIEW.exe" "path_to_vi"
    "C:\Program Files\National Instruments\LabVIEW 2012\LabVIEW.exe" "path_to_vi"
    to use 32-bit and 64-bit development systems respectively. However Labview opens file with version which was last used before. Are there any ways to force it use specified version?

    No, it's a VI I wrote so that when I open any VI from Windows Explorer it will open it in correct version of LabVIEW according to it's source version (rather than the latest/last version of LabVIEW I opened). All it does to launch the right version of LabVIEW is to call System Exec with the path to the correct version of the LabVIEW.exe and the path to the VI - which is essentially the same as what your batch file is doing.
    Certified LabVIEW Architect, Certified TestStand Developer
    NI Days (and A&DF): 2010, 2011, 2013, 2014
    NI Week: 2012, 2014
    Knowledgeable in all things Giant Tetris and WebSockets

  • Writing to file with specific encoding in unix

    hi,
    I want to write html files which contain Turkish characters in unix operating system.
    I'm currently using FileWriter to write the files.
    I'm getting the file content from the database and I can see that the characters seem to be fine but when I write them into an html file, they are displayed with the question mark character (?).
    What can I do about this?
    Thanks

    FileWriter uses the default character encoding of whatever platform your program is running on. Beside the fact that the default encoding may vary from one machine to another, it may not be suitable for storing non-ASCII (Turkish) characters.
    Rather than using FileWriter, you can use an OutputStreamWriter and a FileOutputStream, which allows you to specify the character encoding you want. UTF-8 is generally a good choice, since it can encode just about anything. For example:FileOutputStream fos = new FileOutputStream("/some/file/name");
    OutputStreamWriter osw = new OutputStreamWriter(fos, "utf-8");
    osw.write("your text with Turkish characters...");Geoff

  • Creating folder or file in specific path

    Hi,
    Can we create files or folders in a specific path (could be on a remote server also) using oracle?

    Oracle does not provide functionality per se to perform such O/S level creations.
    You may be able to use Chris Poole's XUTL_FTP package to issue the commands via FTP server:
    http://www.chrispoole.co.uk/apps/xutlftp.htm
    (Can't remember if Chris implemented the FTP md command, but I think he did)

  • Links to PDF files with relative paths from a Captivate 4 project

    I'm creating a presentation in Captivate 4 (I'm making an exe file) with some links to PDF files; the links are buttons with the 'open URL or file' set. The presentation will be distributed in CDs and obviously the links will not work for they point to an absolute path in my PC. Is there another way to display external files? thanks

    "file:\file folder\filename" is not a relative path.  It's still an absolute path because you're specifying the path all the way from the root drive, whether you used a drive letter or not.
    A relative path shows where to find the other file in relation to the file that is calling it.
    Relative paths look like this:
    myDoc.doc (if the file is in the same directory as the file calling it)
    folderName/myDoc.doc (if the file is inside a folder in the same directory as the file calling it)
    ../myDoc.doc (if the file is located in the parent directory above the file that is calling it)
    ../../myDoc.doc (if the file is located two levels above the file that is calling it)
    etc
    Here's a tutorial that explains it better: http://www.communitymx.com/content/article.cfm?cid=230ad

  • Strain measurment and write to file with NI9237

    Hopefully this lab view VI can help some of the novices like myself to acquire strain using the NI9237 and write to a file.  The example VI available from NI "Cont Acq Strain Samples (with calibration)" is fine for sampling data and viewing on a chart, but you need to add your own elements if you want to logg data or write to a file.
    Since aquistion is continuous, reading and writing data must be done at discrete intervals rather than continuously, or, you will end up with a very large file that can not be easily handles in excel. Also, data gets acquired in "packets" of several samples for each channel, so even if you put a write function within a case structre, as I have done ,and you don't convert the data you get that whole "packet" every time the comand writes to file. Again, you will end up with a lot more data points than you would like.
    Though the top level VI is pretty simple, it took me some time and help from many folks for me to figure out what was going on.  I thought I would share.
    Thanks to Sandra T, Jarrod B, Kyle B, Marc A, Herbert E and Jesse O. for your help
    Next goal is to acquire voltage from a different Daq card, convert to load and graph and write load vs. displacement.
    hopefully the attached files are the correct method so the VI fuctions with its sub-VI's.  If not let me know.
    Regards,
    Alfonso
    A. Lopez
    Attachments:
    Cont Acq Strain-Qbridge-I-write to file-NI9237.vi ‏199 KB
    Measure Strain.llb ‏238 KB

    Alfonso,
    I'm glad you got your application running.  It is also nice that you are wanting to share your code.  NI is currently testing a new system that allows community members to share code.  If you like, you can also submit your code here.
    Regards,
    Jesse O.
    Applications Engineering
    National Instruments
    Jesse O. | National Instruments R&D

  • How to get InputStream from a file with absolute path?

    Hi, guys:
    If I have file with a absolute path that may be inside/outside
    my Eclipse plugin, I want to get an InputStream from it. It just keeps giving me null for "is":
    String absFilePath = "/D:/my_dir/.../sample_file.txt";
    InputStream is = getClass().getResourceAsStream(absFilePath);
    regards,

    Don't use resource as stream if you have an absolute path, use FileInputStream.

  • How to execute sql files with windows path ?

    Hi , here's my stupid question :
    I have my parent SQL script say A.sql in directory C:\program files\my files\A.sql
    A.sql has calls to multiple sql files like this
    @@1.sql;
    @@2.sql;
    When I call A.sql using sqlplus as:
    sqlplus <username> <connection_string> @"C:\program files\my files\A.sql"
    A.sql gets executed but then while calling "1.sql" it fails with the error
    SP2-0310: unable to open file "C:\program.sql"
    This is happening because of the space, how can this be handled. thx in advance :)
    Regards,
    Neuron

    my A.sql is:
    @@1.sql
    @@2.sql
    1.sql and 2.sql are in the same directory as A.sql.
    sqlplus <username> <connection_string> @"C:\program files\my files\A.sql"
    VG2,
    Yes. Specify the entire path/filename and put double quotes around itA.sql has the double quotes around it, however what additional things can be done so that 1.sql and 2.sql which are present in same directory as A.sql also runs.
    Ashish,
    Yes the assumption is correct. Although when I cd to this directory then this issue won't come for sure.
    But the requirement is you can't 'cd' to the directory and want to execute with complete path.
    There is no issues in Solaris as the space is not allowed.

  • "AVI2 Write Frame" not working on files with "µ" in path

    This is a Bug report!
    Please have a look at the attached VI. The AVI file is created but no data is written and the Write Frame function reports error "-1074395969".
    If I change the path to something without "µ" it's working! Tested in the 2013 Version.
    Attachments:
    AVI2WriteFrameBug.vi ‏17 KB

    Hi Madir123,
    Can you downconvert it to 2012 version and post please ???
    Thanks
    Thanks
    uday,
    Please Mark the solution as accepted if your problem is solved and help author by clicking on kudoes
    Certified LabVIEW Associate Developer (CLAD) Using LV13

  • Retaining formating of text when write new file with FILEIO

    Hi all,
    I wonder if there is any way to retain the formating of the
    text when I write it in a new file using FILEIO. In particular I
    have the following text in a field member:
    test <background = L1_garaz/> (text in the tag has
    color and itsbold) test
    I use the following code to write the above text in a new
    filw using FILEIO:
    on mouseup
    annot = member("annotator").text
    path = the moviepath & "Annotated_text\"
    whichanno = baGetFilename( "Save", ""&path&"", "",
    "doc files|*.doc", 0, "Save doc file", 0, -2, 0 )
    myanott = new(xtra "FileIO")
    myanott.createfile(whichanno) --create
    myanott.openFile(whichanno,0)
    writeString(myanott,annot) --write the new string
    myanott.closeFile()
    myanott = VOID
    end
    the problme is that despite the type of file that i will
    choose to save it (.doc, txt , etc) it refuses to save the text
    with its initial formating (with the color, and bold words). Any
    idea how to solve this?

    "wgb14" <[email protected]> wrote in message
    news:fc7nf2$av3$[email protected]..
    > Hi all,
    >
    > I wonder if there is any way to retain the formating of
    the text when I
    > write
    > it in a new file using FILEIO. In particular I have the
    following text in
    > a
    > field member:
    >
    > test <background = L1_garaz/> (text in the tag has
    color and itsbold)
    > test
    >
    >
    > I use the following code to write the above text in a
    new filw using
    > FILEIO:
    >
    > on mouseup
    >
    >
    > annot = member("annotator").text
    > path = the moviepath & "Annotated_text\"
    > whichanno = baGetFilename( "Save", ""&path&"",
    "", "doc files|*.doc", 0,
    > "Save doc file", 0, -2, 0 )
    >
    > myanott = new(xtra "FileIO")
    >
    > myanott.createfile(whichanno) --create
    > myanott.openFile(whichanno,0)
    > writeString(myanott,annot) --write the new string
    > myanott.closeFile()
    > myanott = VOID
    >
    > end
    >
    > the problme is that despite the type of file that i will
    choose to save it
    > (.doc, txt , etc) it refuses to save the text with its
    initial formating
    > (with
    > the color, and bold words). Any idea how to solve this?
    >
    What file format do you use to save the text?
    Of course you need to use an appropriate file-format, or
    invent your own.
    Maybe try HTML or RTF.
    Richard.

  • Importing data from third party file with specific layout

    Hello everyone,
    I have been searching the forum and googling for help on this but so far no success.
    The issue I have is the following:
    - I need my client to provide data to me in 2 different dates (Date 1 and Date 2), for example, a bank account balance;
    - He has already provided me with data for "Date 1" in the previous year and this information is stored in a file, generated by a government software;
    - I have the file layout provided by the government, establishing the location and number of characters where the information is stored (e.g. need to import characters 4-12 of a specific line in the file);
    - I need to be able to read from this file and pre-populate field "Date 1" with the amounts informed previously;
    - I will then send a PDF form for him to update the "Date 2" field, using the amount in "Date 1" as a reference.
    Is there any way I can do this?
    I like researching and do this as a hobby, therefore I don't expect to receive pieces of code already prepared - I would just appreciate if anyone could point me in the right direction here, as my coding skills are from a guy interested in learning things.
    Many thanks in advance for all the help.
    P.S.: the government software can generate a .PDF file and the data I need is reported there, just in case it is easier to work with a PDF file instead.

    Hi,
    Looks like that you are using relative path. Then, the file must be located in MathScript search path. Otherwise, MathScript can not find that file. You can either specify the absolute path or add the path to MathScript search path list.
    I have tried in LabVIEW 8.6. dlmread should work well to read data from .txt file.

Maybe you are looking for

  • Mail setup and .mac authentication

    Baffled- I have been trying to setup my Mail account. I have an active .Mac account which I can access via the internet, so I know it works. I am trying to use Mail as my automatic mail for sending Aperture photos and iWeb announcements. In going thr

  • SAP XI 7.0 (NetWeaver 2004s) Certification

    Hello All, I am planning to write SAP XI 7.0 (NetWeaver 2004s) Certificataion.but, i need C_TBIT44_70 material. Please send me if any one having C_TBIT44_70 material. my id : [email protected] Points should be allot .... Thanks, Mahesh

  • ODS ACTIVATION GIVING TIME EXCEEDING RUNTIME ERROR

    Hi experts, I am working on BW 3.5 i am adding two fields in a existing ODS as i have enhanced  a Datasource with that field now when i am adding these 2 fields by drag and drop and than activating the ODS its giving Run time error showing TIME LIMIT

  • Cannot access Facebook since Mavericks upgrade

    Since I updated my Snow Leopard to Mavericks about a month ago, I've been unable to access Facebook through Safari, Google Chrome, or any other browser. However, I'm still getting Facebook message notifications via the notification centre. I am very

  • Dropped Frames instantly after beginning to capture

    I've been uploading video and had no problem, then randomly at one point I got the 'dropped frames' message, and now I get it instantly after clicking capture... I feel like it's something with the computer, since the video plays back fine until I cl