Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied! <p>This is expected when using i.e. <code>createTempFile</code> method as it implicitly creates a file with random prefix:</p> <pre class="lang-java prettyprint-override"><code>// a part of createTempFile method private static final SecureRandom random = new SecureRandom(); static File generateFile(String prefix, String suffix, File dir) { long n = random.nextLong(); if (n == Long.MIN_VALUE) { n = 0; // corner case } else { n = Math.abs(n); } return new File(dir, prefix + Long.toString(n) + suffix); } </code></pre> <p>which should give something like 'test.xml13234xml'.</p> <p>If you want to create a file with the correct name and keep it for later use you can rename/move it within <code>uploadSucceeded</code> method. </p> <pre class="lang-java prettyprint-override"><code>public class ExampleUpload implements Upload.Receiver, Upload.SucceededListener { private Upload xmlUpload; private File tempFile; public ExampleUpload() { this.xmlUpload = new Upload("Upload:", this); this.xmlUpload.addSucceededListener(this); } @Override public OutputStream receiveUpload(String filename, String mimeType) { try { tempFile = File.createTempFile(filename, "xml"); tempFile.deleteOnExit(); return new FileOutputStream(tempFile); } catch (IOException e) { e.printStackTrace(); } return null; } @Override public void uploadSucceeded(SucceededEvent event) { try { File destinationFile = new File("c:\\" + event.getFilename()); FileUtils.moveFile(tempFile, destinationFile)); // TODO read and parse destinationFile } catch (IOException e) { e.printStackTrace(); } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload