How to create a new file

hello
    how to create a new file myfile.txt in folowing URL
     http://www.mydomain.com/upload/myfile.txtregards

the_Orient wrote:
corrected code
I will to create a text file on webserver
this file hasethe content "Hello World"
</div>
try
String  S="Hello World"
     URL url = new URL("http://www.mydomain.com");
     URLConnection hpCon = url.openConnection();
     hpCon.setDoOutput(true);
     File file = new File("http://www.mydomain.com/studentes/info.txt");
     file.createNewFile();
// how to use FileOutputStream  here
OutputStreamWriter out = new OutputStreamWriter(hpCon.getOutputStream());
     out.write(content);
     out.close();
}catch(Exception ex){ex.printStackTrace();}     
Exception :
java.io.IOException: The filename, directory name, or volume label syntax is incorrect
{code}
regards
Whoa! Do you know what you're doing? Do you have permission to write on that URL? Or does the pathname parameter you passed on File is correct? How about let the server-side handle the creation of file for you by just requesting it? Do you know how to create a server-side Java program (e.i. Servlet)? Umm.. There's a Java tutorial for this for you to get started: [Reading from and Writing to a URLConnection|http://java.sun.com/docs/books/tutorial/networking/urls/readingWriting.html].
Ron
Server-Side Development Team
[Java-Man 2004|https://sites.google.com/site/raisoftware6/]

Similar Messages

  • How to create a new file - help please.

    hi there
    i need to create a new file in my program, i did the following:
    /*code--------------------
    PrintWriter out = new PrintWriter(new FileOutputStream(new File("c:\\somedirectory\\outputfile.txt")));
    out.println("product code:"+productCode);
    out.println("product price:"+productPrice);
    out.println("product description:"+productDes);
    out.flush();
    out.close();
    the directory c:\somedirectory\ does not exist yet. i was hoping that when the new file is created, so was the directory. when i run it. the program could not find the path with following error message:
    c:\somedirectory\outputfile.txt (The system cannot find the path specified)
    can anyone of you experts point a rigth solution? thank you.

    thanks
    so the steps to create a new file in a new directory is as follow:
    //create a file object with the directory path
    File d = new File("c:\\xx\\");
    d.mkdir();
    //then create another file object with the path and the file name
    File f = new File("c:\\xx\\abc.txt");
    is this right?

  • How to create a new file (doc, ppt or xls) using the secondary click??

    Is there any way to create a new file(text, doc, docx, ppt, pptx, xls or xlsx) using the the secondary click (on the desktop or any folder) just like creating a new folder using secondary click! Please do let me know!

    No. You need the Office applications to create them or another application capable of creating those types of files or at least saving files in those formats.

  • How to create a new file with existing file's resource fork?

    Hello,
    I would like to create a new file that has the resource fork of an existing file. I had though of making a copy of the existing file, seek to the beginning of the copy and write the new data, but for large files, that creates the whole file even when not needed. I currently create the new file with [NSFileManager createFileAtPath: contents: attributes:], but attributes do not include resource fork items, like custom icons, color label, etc.
    [NSURL resourceValuesForKeys] gives a common subset of resource data, like icons and color label, but that's about it. Is there some way to get the resource fork or a copy of the file without getting the whole file?
    Thanks

    What are you trying to do here? While resource forks might still be quasi-supported, you really shouldn't be thinking about them as such. Instead, think in terms of extended attributes. You can use the low-level xattr() functions to get some of that or you can use the new NSURL methods.

  • How to create a new file  having a name that is stored in a string

    Hello friends i am new to java and i need your help .
    I have a string which will take different values at run time. I want to create a file which has the same name as stored in the string . Can anyone help me?

    The Java Almanac example I linked to uses createNewFile() - the API documentation is not particularly clear about exactly what happens if c:\some\value\assigned\at doesn't already exist. But you're only a small experiment away from finding out!
    Another page gives examples of directory creation.
    http://www.exampledepot.com/egs/java.io/CreateDir.html
    Once (or if) the file is created using a File then, yes, that File is the name of the file: parent directories and all. If you create a FileReader based on the File it will read from the right place.

  • How to create a new session in JSP file

    Usually a child IE window uses same session with parent window. Dose someone know how to create a new session when creating a new IE window by clicking a URL in parent window? The web page is writen by jsp file.

    I am not sure of your question. Are you wanting to have 2 Session objects (one for the parent window and another for the child)?
    A session is usually created once per client and is stored on the server the session id is carried around in a cookie or a URL rewrite so that everytime the user submits a page you will be able to store/access information.
    // this will create a new session object if one doesn't already exist.
    HttpServletRequest.getSession( true );
    Hope this helps

  • How do I automatically create a new file at the beginning of a new day, otherwise I only want to append that days file?

    In my robotics application I store my data using "Write to Spreadsheet.vi". I would like to append the file each time I run the program on any given day. On a NEW day I would automatically like to create a new file with a smiliar name and append that file for the day on which it is created. It's easy to do using the "Write to Measurement File. vi" but the text file created is vertical rather than horizontal, so I would like to use "Write to Spreadsheet". Any suggestions?
    Also how to I include my VI as part of this question for others to see?
    Thank you.
    Attachments:
    Untitled 4 (SubVI).vi ‏7 KB

    Does the file you are writing have a timestamp in it?  If so you could read the timestamp from the last time it was written and see if the day has changed, handling the name of the file appropriately.  The easiest way to record the timestamp is probably to write the timestamp as the number of seconds that have elapsed since 12:00 am on Firday January 1st 1904 in UT.  The "Get Date/Time in Seconds" function will give you this value.
    Message Edited by jmcbee on 03-05-2009 12:56 PM
    CLA, CLED, CTD,CPI, LabVIEW Champion
    Platinum Alliance Partner
    Senior Engineer
    Using LV 2013, 2012
    Don't forget Kudos for Good Answers, and Mark a solution if your problem is solved.

  • How to create a new user id in OID for Oracle Collab suite File System

    Dear Friends,
    I want to know how to create a new user id in the oracle internet directory where i can use that user for the new subscription of the oracle collabration suite file system..
    Please do the needfull and thanks in advance...
    With warm regards
    R.Prasad

    Hi!
    The way you suggest should not be used.
    A CS user will be created as a normal OID user and will receive the CS attributes in a different subtree later during the provisioning.
    For creating CS users use oesuser and uniuser. Files provisioning will work in a different manner anyway.
    cu
    Andreas

  • How to create a new excel file using Excel Destination when Destination file not exists.

    how to create a new excel file using Excel Destination when Destination file not exists.

    Just need to set an expression for excel connectionstring and set delay validation to true and it will create it on the fly.
    The expression should return the full path with dynamic filename in each case.
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • How do i create a new file in pdf

    I JUST STATED IN ADOBE , WOW DO I CREATE A NEW FILE IN PDF

    Hi Robert,
    Welcome!
    I see you are subscribed to our PDF Pack service.
    Check out this FAQ to help get you started!
    Let me know if this helps.
    Looking forward to hearing back from you!
    Kind regards, Stacy

  • How can I interactively create a New File in LabVIEW 2011?

    I am trying to create a new binary file interactively in LabVIEW, but the File Path control only offers the ability to either type in the full path and file name (cumbersome for the user), or browse for an existing file. I want to open a "New File" dialog that will allow the user to browse to the target directory, then be able to enter the name of a non-existing file to save the data to.
    The way I'm currently doing it is creating a TXT file using the Windows Explorer "New Text Document" pop-up, then changing the file extension to the new value...which is again, very cumbersome.
    The only thing I've found online is that there used to be a "New File.VI" in an older version of LabVIEW apparently...but I can't seem to find it in 2011.
    Solved!
    Go to Solution.

    You can create a new file using the browse button.
    Did your right click on the file path control and check the settings in the "Browse Options" menu?

  • How to create a new partion in my HP (Compaq LE1902x )PC that has already 4 primary partitions ?

    How to create a new partion (to save my files & Folders) in my HP (Compaq LE1902x )PC that has already 4 primary partitions ? when something goes wrong along with OS(C) drive my all files are lost. so i want to create a new partition & dedicate it to my files & folders.

    I would consider another problem. What if the hard drive (not the OS) fails. You'd lose all your data, all partitions. It seems better logic would be to copy your files and folders to either an external hard drive or USB thumb drive.
    I would not use the internal backup program, but would manually copy the data. I also would not leave such device attached to the computer.
    In my system I have a separate USB thumb drive that stored critical medical and legal documents. That way, I can travel with it, as needed. I also clone my primary desktop every 30-45 days. That way, if I get a failure, it's only that far back on lesser files.
    I am a volunteer. I am not an HP employee.
    To say THANK YOU, press the "thumbs up symbol" to render a KUDO. Please click Accept as Solution, if your problem is solved. You can render both Solution and KUDO.
    The Law of Effect states that positive reinforcement increases the probability of a behavior being repeated. (B.F.Skinner). You toss me KUDO and/or Solution, and I perform better.
    (2) HP DV7t i7 3160QM 2.3Ghz 8GB
    HP m9200t E8400,Win7 Pro 32 bit. 4GB RAM, ASUS 550Ti 2GB, Rosewill 630W. 1T HD SATA 3Gb/s
    Custom Asus P8P67, I7-2600k, 16GB RAM, WIN7 Pro 64bit, EVGA GTX660 2GB, 750W OCZ, 1T HD SATA 6Gb/s
    Custom Asus P8Z77, I7-3770k, 16GB RAM, WIN7 Pro 64bit, EVGA GTX670 2GB, 750W OCZ, 1T HD SATA 6Gb/s
    Both Customs use Rosewill Blackhawk case.
    Printer -- HP OfficeJet Pro 8600 Plus

  • How to create a CSV file in java

    how to create a CSV file in java

    this is the code that I have used in a hp project:
    private static final String DELIMIT = ",";
    StringBuffer buf = new StringBuffer();
    public void addString(String str){
    buf.append(toEscapedStringLiteral(str.replaceAll(" ","").trim())).append(DELIMIT);
    public void sendFile( String strData ,
                                String strTitle,
                                String strContType,
                                HttpServletResponse res ) throws IOException {
              byte[] _filedata=strData.getBytes();
              res.setContentType( strContType );
              res.setHeader( "Content-Disposition", "attachment;filename="+ strTitle );     
                     DataOutputStream out = new DataOutputStream( res.getOutputStream() );
              out.write( _filedata, 0, _filedata.length );
              out.close();
    public void addStringWhithReturn(String str){
              buf.append(toEscapedStringLiteral(str.replaceAll(" ","").trim()));
              buf.append( "\n" );
    private String toEscapedStringLiteral( String charSeq ) {
              if ( null == charSeq ) {
                   charSeq = "";
              return "\"" + charSeq + "\"";
    ....hope its help
    kou

  • How to create a new account and copy all settings?

    I think my main user account is corrupted. So I want to create a new account and copy all of my settings, files etc..and more than likely piecemeal just incase my settings are what is corrupted. That way I can isolate the problem.
    I don't plan to delete the main account until satisfied and I also have my Time Machine backup plus my SuperDuper backup.
    I can/should be able to figure out how to create the new account, but I am very unclear on the best/easiest approach to copy in my iTunes files and settings, applications(is this even an issue), address book, email, etc? I should be able to find most everything underneath my home account folders but what else am I missing here? I don't want to find out the hard way.
    Please share some advice or perhaps a link/FAQ on how to approach.
    Thanks in advance.
    --Mickey

    use this [link|http://discussions.apple.com/message.jspa?messageID=6185507].

  • How to create a PAR file from EAR file

    Hi,
       I have created an Web Dynpro Application . When i deploy it in Remote J2EE Engine, it will deploy as EAR file. It then runs as normal Web Application in Web browser. My requirement is to create an iView for my Web dynpro appn in EP. That is possible only by creating a PAR file. so How to create an PAR file from EAR in NWDS(NetWeaver Developer Studio).
    How to access the EAR file in NWDS or J2EE ?
    Thanks in Advance ,
    By
    Saravanan

    Hi,
    To create a iview,
    log on to portal, New iView and select SAP webdynpro iview.
    It will ask for namespace which is usually , local/Project Name
    and application name is the name of the application.
    We dont have to create par file for this requirement

Maybe you are looking for

  • G40 Video noise and blank

    Upon startup, myG40 shows the POST page, then I hear a high pitch noice briefly, and the display goes dark. The external video connector does work, but the lcd screen stays dark. I have a second machine that I can use for parts.  Can someone recommen

  • Merging clips with diff Aud Vid sources

    Does anyone know a way to successfully merge Audio & Video from separate sources with diff TC to make an independent clip but keep the same TC from the Video? I have video from DV CAM tapes, but the audio was recorded on DATs. The TC on the DATs is s

  • Telnet with Run Program Activity

    Hello Experts, I have a quick question with respect to the Run Program Activity. Is it possible to have a telnet session with the run program activity without loosing the connection ?  So my first activity will be the telnet connection. Once the conn

  • Sapscript Formatting

    Hi everyone. I am have this piece of code in SAPscript MAIN window editor: /:   IF &PAGE& = 1 /:   POSITION XORIGIN '0.2' CM /:   BOX WIDTH '77' CH HEIGHT '190'MM FRAME 10 TW /:   BOX WIDTH '77' CH HEIGHT '1.2'LN FRAME 20 TW /:   BOX XPOS '17' CH WID

  • I can't find DPS Tools panels in InDesign CC

    I installed InDesign CC and it's updated, but I can't find the panels Folio Builder and Overlays in the Window menu. I had alread uninstalled and installed again, but it doesn't work. I work in a PC with Windows with windows 7 professional. I don't h