Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Append text in file. and save it

821106Dec 4 2010 — edited Dec 4 2010
Append text in file.

hi!
i am new j2me Programer.

1.i want to add(APPEND) the text in the file. i take this code form internet but i could succed Please help me.

2.i want to save it in other directory like if i made folder on mobile device with name c:\Old i want to save file in that how could i ?

kindly mention the Mistake.





package FileConnection;

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.io.*;
import javax.microedition.io.*;

/**
* @author QTracker
*/
public class FileConnection extends MIDlet implements CommandListener {

private boolean midletPaused = false;

private Command exit, start;
private Display display;
private Form form;
public FileConnection ()
{
display = Display.getDisplay(this);
exit = new Command("Exit", Command.EXIT, 1);
start = new Command("Start", Command.EXIT, 1);
form = new Form("Write To File");
form.addCommand(exit);
form.addCommand(start);
form.setCommandListener(this);
}

private void initialize() { }
public void startMIDlet() { }
public void resumeMIDlet() {/
}
public void switchDisplayable(Alert alert, Displayable nextDisplayable) {

Display display = getDisplay();
if (alert == null) {
display.setCurrent(nextDisplayable);
} else {
display.setCurrent(alert, nextDisplayable);
}
}
public Display getDisplay () {
return Display.getDisplay(this);
}


public void exitMIDlet() {
switchDisplayable (null, null);
destroyApp(true);
notifyDestroyed();
}

public void startApp() {
display.setCurrent(form);
}

public void pauseApp() {
midletPaused = true;
}


public void destroyApp(boolean unconditional) {
}

public void commandAction(Command c, Displayable d) {
if (c == exit)
{
destroyApp(false);
notifyDestroyed();
}
else if (c == start)
{
try
{
OutputConnection connection = (OutputConnection)
Connector.open("file:\\c:\\myfile.txt;append=true", Connector.WRITE );
OutputStream out = connection.openOutputStream();
PrintStream output = new PrintStream( out );
output.println( "This is a test." );
out.close();
connection.close();
Alert alert = new Alert("Completed", "Data Written", null, null);
alert.setTimeout(Alert.FOREVER);
alert.setType(AlertType.ERROR);
display.setCurrent(alert);
}
catch( ConnectionNotFoundException error )
{
Alert alert = new Alert(
"Error", "Cannot access file.", null, null);
alert.setTimeout(Alert.FOREVER);
alert.setType(AlertType.ERROR);
display.setCurrent(alert);
}
catch( IOException error )
{
Alert alert = new Alert("Error", error.toString(), null, null);
alert.setTimeout(Alert.FOREVER);
alert.setType(AlertType.ERROR);
display.setCurrent(alert);
}
}
}

}

Comments

Roadling

I was able to duplicate the issue running latest version of FF on Windows 8.1 as well

Regards,

Brad

AquaNX4

This has been a crazy issue for me for at least 4 months now, and we run Windows 7 and Chrome at work.  This is def a bug....

Aqua

Hi Denes,

This is interesting, thanks for the details. I don't know yet what's causing this, but think it may have something to do with Windows 8.1's touch events. Will keep looking into it, in the mean time, can you also provide the following:

  1. IE version where this works?
  2. Windows 8.1 exact version?

Regards,

Anthony.

Denes Kubicek

Thanks to both of you. That means I don't see pink elephants. The majority of tests was probably done using fancy Apple laptops and gadgets.

Denes Kubicek

Denes Kubicek

Hello Anthony,

Thanks for responding.

I have IE 11 and there it works. My version is Windows 8.1 with a touch screen. However AquaNX4 just confirmed the same issue on Windows 7.

Regards,

Denes Kubicek

Anthony Rayner-Oracle

Hi Aqua,

Just to clarify:

  1. Do you mean you've been hitting this issue in a pre 5.0 version of APEX for 4 months, or in APEX 5 using EA releases?
  2. Which version of Windows are you using?
  3. Which version of Chrome?
  4. Can you also try with IE and let us know if this also works correctly with IE, and which version you have?

Thanks in advance.

Anthony.    

AquaNX4

Yup.  You explained the behavior exactly as it occurs in our environment.  Right after an end-user clicks on the calendar icon, the calendar opens and closes very quickly.  However, when you click on it a second time it behaves normally, which is interesting, because the abnormality occurs only on the first click event.  Don't know what it could be, so I will leave it to the professionals...

Aqua

Hi Denes,

Thanks. Does Windows provide any greater specificity of version than 8.1? I ask, because another customer reported an issue with the IR actions menu button not working at all with Windows 8.1 and Chrome / FF, but did work in IE. They then installed a Windows updated and were thereafter unable to reproduce the issue. It's not exactly the same issue, but similar enough to warrant suspicion, hence it would be interesting to know any more specific version if possible? I will try and find out which update they installed that seemed to rectify their issue.

Regards,

Anthony    

AquaNX4

Anthony:

1:  Yes, the problem persists on 1 server we run with APEX 4.2.6

2:  Windows 7 Professional

3:  Chrome version 42

4:  I will try with IE and let you know...

Aqua

Denes Kubicek

Hello Anthony,

I have the latest Windows 8.1 Pro Updates installed on my computer. This is the information in more details

pastedImage_0.png

Regards,

Denes

Denes Kubicek

Anthony,

I have the same issue with the IR Action Button. When I press "Go" and the report refreshes, the Action Button will work properly. If I reload the page it will again cause troubles.

Denes Kubicek

Morning all,

A brief update on this. I was able to download and install a Windows 8.1 Enterprise VM overnight, running on OS X 10.10.3. However, much to my disappointment, I'm still unable to reproduce any issues as reported. I tested Denes' example with latest FF and Chrome in 8.1.

To try and pin this down, I'm going to first focus on the 8.1 scenario. On my setup, I have no touch display and Windows appears to know this, because if I go to Windows Start page, type 'pc info', then view the 'Pen and Touch' setting, this says 'No pen or touch input available for this display'. This feels like something that could be relevant. Denes, I assume if you check this, you see something different here? And is it possible to disable the touch screen somehow and retest your scenarios?

Regards,

Anthony.

Anthony Rayner-Oracle

All,

In addition, after some research, could you try something else as well? It appears Windows 8.1 has a setting that delays clicks in the touchpad, apparently to 'help prevent the cursor from accidentally moving while you type'. This by default is set to 'Medium Delay', which again sounds somewhat relevant andcould explain why things work as expected with a slow click (although doesn't really explain the fast click duplicate events granted). This Microsoft support article talks about this, along with the steps to disable this by setting it to 'No delay (always on)'. Perhaps you could try setting this and see if that makes any different for you?

Regards,

Anthony

Denes Kubicek

Anthony,

Thanks for looking into the issue.

1. I did disable the touch screen and no changes.

2. I did change the delay to no delay for the touchpad and no changes.

Please note:

1. This happens only with the Universal Theme - not with other themes.

2. I have the same issue with the IR Action Button. But, when I first press "Go" Button and the report refreshes, the Action Button will work properly. If I reload the page it will again cause troubles.

Denes Kubicek

Denes Kubicek

Anthony,

Just tested the same thing with the Theme 26 at apex.oracle.com and there are no issues at all.

Denes Kubicek

Hi Denes,

Ok, thanks for trying that there. Will keep looking into it. By the way, with the IR actions button, what exactly do you see happen, nothing when you click it until you have hit 'go', or some kind of duplicate behaviour until you hit 'go'?

Regards,

Anthony.    

jstephenson

Hello Denes,

I am glad that you brought this up.  I saw this in the EA, but I thought it had something to do with the fact that I was using my Microsoft Surface(Windows 8.1).  I see the same problems you mentioned including the button in the upper left of the screen that allows you to shrink the left navigation bar.  I then decided to check my work laptop which is running windows 7, but has a touch screen.  This shows the same behavior.  So based on that I looked at my son's computer running Windows 8.1 but does not have a touch screen and it worked without any issues on all 3 browsers.  Seems to be touch screen related?

I don't want to get on a tangent, but I see similar behavior with the slide tooltip plugin.  If I set it to tooltip using one of my touch screen computers it works fine on IE, but in FF and Chrome it shows the drop down button. If I use a non touch screen computer it works fine on any browser.  Just thought I would mention it in case it helps troubleshoot the issue.

Thanks,
Jeff

Roadling

I dont have a proper environment to test  this today but I was struck by how familiar to what Denes reported when I was searching around known issues with bootstrap.

Use case 2: Twitter Bootstrap 2.2.2 dropdowns

Another example of when to use the needsclick class is with dropdowns in Twitter Bootstrap 2.2.2. Bootstrap add its own touchstart
listener for dropdowns, so you want to tell FastClick to ignore those.
If you don't, touch devices will automatically close the dropdown as
soon as it is clicked, because both FastClick and Bootstrap execute the
synthetic click, one opens the dropdown, the second closes it
immediately after.

<a class="dropdown-toggle needsclick" data-toggle="dropdown">Dropdown</a>

https://github.com/ftlabs/fastclick#when-it-isnt-needed

and I got to fastclick looking at

https://github.com/CWSpear/bootstrap-hover-dropdown/issues/28

Regards,

Brad

Denes Kubicek

Anthony,

the Action Menu doesn't open.

I think that 's answer is on the right track.

Denes Kubicek

Anthony Rayner-Oracle

All,

Sorry for the delay in following up. This does indeed seem to be related to Roadling’s response, and the cited Google article from the fastClick library about Fast Buttons. That article talks about the much discussed 300ms delay mobile browsers employ after a tap, to fire the corresponding click event. This definitely seems related. I've still not been able to reproduce any issues, either on my Windows 8.1 VM (with no touch), or on any other mobile browser, tried both iOS Safari and Chrome on Android.

I have written a test app to try and exercise the various reported issues, and hopefully isolate this further. The first app 77638 uses Universal Theme without jQuery Migrate included (which is the default for new apps), then there is another app (97763), which is a copy of the first but does include jQuery Migrate in the User Interface settings.


Test app without jQuery Migrate

Test app with jQuery Migrate

(Both login as guest/orclapex)

If at all possible, could anyone on this thread who has been able to reproduce any of these issues, run through the tests in these apps and report their results back here. There are 6 test pages in each app, each test should be exercised with a ‘fast click’ as Denes describes (so just a normal, swift click and release of the mouse), just follow the menubar items along from left to right, and answer the questions posed on each page:

OS:

Touch Device: Yes / No

Browser:

For application 77638 without jQuery Migrate:

Interactive Report Test - Yes / No

Datepicker Test - Yes / No

Tabular Form Datepicker Test - Yes / No

Dynamic Action Test - Yes / No

JavaScript Click Test - Yes / No

JavaScript fastClick Test (Using the fastClick library) - Yes / No

For application 97763 with jQuery Migrate:

Interactive Report Test - Yes / No

Datepicker Test - Yes / No

Tabular Form Datepicker Test - Yes / No

Dynamic Action Test - Yes / No

JavaScript Click Test - Yes / No

JavaScript fastClick Test (Using the fastClick library) - Yes / No

Greatly appreciate anyone’s further input in helping to pin this down.


Regards,

Anthony.

Roadling

OS: Windows 8.1 Professional

Touch Device: Yes



Browser: Firefox 37.0.2

Yes = works as expected   No = Not working as expected

For application 77638 without jQuery Migrate:

Interactive Report Test - NO

Datepicker Test - NO

Tabular Form Datepicker Test - No

Dynamic Action Test - Yes

JavaScript Click Test - Yes

JavaScript fastClick Test (Using the fastClick library) - Yes

For application 97763 with jQuery Migrate

Interactive Report Test - NO

Datepicker Test - NO

Tabular Form Datepicker Test - No

Dynamic Action Test - Yes

JavaScript Click Test - Yes

JavaScript fastClick Test (Using the fastClick library) - Yes


-----------------------------------------

Browser: IE 11.0.9600

For application 77638 without jQuery Migrate:

Interactive Report Test - Yes

Datepicker Test - Yes

Tabular Form Datepicker Test - Yes

Dynamic Action Test -  No

JavaScript Click Test -  No

JavaScript fastClick Test (Using the fastClick library) -  No

For application 97763 with jQuery Migrate

Interactive Report Test - Yes

Datepicker Test - Yes

Tabular Form Datepicker Test - Yes

Dynamic Action Test -  No

JavaScript Click Test -  No

JavaScript fastClick Test (Using the fastClick library) -  No


-----------------------------------------


Browser: Chrome 42.0.2311


Yes = works as expected   No = Not working as expected

For application 77638 without jQuery Migrate:

Interactive Report Test - NO

Datepicker Test - NO

Tabular Form Datepicker Test - No

Dynamic Action Test - Yes

JavaScript Click Test - Yes

JavaScript fastClick Test (Using the fastClick library) - Yes

For application 97763 with jQuery Migrate

Interactive Report Test - NO

Datepicker Test - NO

Tabular Form Datepicker Test - No

Dynamic Action Test - Yes

JavaScript Click Test - Yes

JavaScript fastClick Test (Using the fastClick library) - Yes

Regards,

Brad

Anthony Rayner-Oracle
Answer

Brad, thanks so much for running those test.

On speaking with the main developers of Universal Theme this afternoon, we have now pinpointed what we believe to be the cause of this issue. There is code in Universal Theme which uses hammer.js, and applies some fast click logic to all links and buttons, with a few exceptions. We believe it is this code that may be causing all these issues.

Please hold fire on performing any more tests as previously requested, apologies for any time wasted on doing so. We will follow up on this thread with findings, as soon as we can.

Thanks again for all your help, thus far.

Regards,

Anthony    

Marked as Answer by Denes Kubicek · Sep 27 2020
Denes Kubicek

Hello Anthony,

I created a Dynamic Action on the Global Page 0 and it runs on Page Load executing the script you asked me to test:

window.Modernizr.touch = false;

This seems to fix the issue for FireFox and Chrome. IE behaves still the same way as before.

Thanks and Regards,

Denes Kubicek

timothyscottchambers-Oracle

Hi,

To add onto Denes remark, if you wish to disable the fast-click action for Window 8 devices, but enable it for non-windows-8 mobile devices, please insert the following code into your "Execute JS" dynamic action on your global page.


(function() { var ua = navigator.userAgent.toLowerCase(); if (/windows nt 6.2/.test(ua) || /windows nt 6.3/.test(ua)) { window.Modernizr.touch = false; } })();


This code simple checks if you're using windows 8, and then disables the fast-click handling. Otherwise, it allows the normal fast-click detection then application to work.


Please let me know if there any issues.


Sincerely,

Tim

1 - 24
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jan 1 2011
Added on Dec 4 2010
1 comment
1,340 views