Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private File createrunbat(String str,String par)
- {
- if(str.startsWith("Text Editor-",0))
- {
- str=str.replaceFirst("Text Editor-","");
- }
- String sng,s2;
- File fe;
- try{
- FileOutputStream fos;
- DataOutputStream dos;
- sng=str;
- int a=sng.indexOf(".");
- sng=sng.substring(0,a);
- file=new File(jfc.getSelectedFile().getParent(),sng+".bat");
- fd=file.getAbsoluteFile();
- str=fd.getParent().substring(0, 2);
- fos=new FileOutputStream(file);
- dos=new DataOutputStream(fos);
- dos.writeBytes("@echo off n");
- dos.writeBytes("cd\"+"n");
- if(fd.getParentFile().isDirectory())
- {
- dos.writeBytes(str+"n");
- }
- s2=jfc.getSelectedFile().getParent();//I am having single quote problem from here
- dos.writeBytes("cd "+s2+"\"+"n");
- dos.writeBytes("javac "+sng+".java"+"n");
- dos.writeBytes("java "+sng+" "+par+"n");
- dos.writeBytes("pause n");
- dos.writeBytes("exit n");
- dos.close();
- }
- catch(FileNotFoundException ex)
- {
- }
- catch(IOException ex2)
- {
- JOptionPane.showMessageDialog(this,ex2.toString());
- }
- return fd;
- }
- Windows cannot find 'C:Program'.
- 'C:Program FilesSomePlace...'
- ^ gets cut on whitespace and becomes two arguments instead of one:
- 'C:Program' and 'FilesSomePlace...'
- '"C:Program FilesSomePlace..."'
- ^ quotes will keep the path together as a single argument
- String safePath = String.format(""%s"", jfc.getSelectedFile().getParent().getAbsolutePath());
- dos.writeBytes ("cd "" + s2 +"""+"n");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement