Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
NOTEPAD.
NOTEPAD I made.
How I add MenuShortcut JUST DELETE in line 9? Plz help me....
ms[0] = new MenuShortcut(KeyEvent.VK_N);
ms[1] = new MenuShortcut(KeyEvent.VK_O);
ms[2] = new MenuShortcut(KeyEvent.VK_S);
ms[3] = new MenuShortcut(KeyEvent.VK_P);
ms[4] = new MenuShortcut(KeyEvent.VK_Z);
ms[5] = new MenuShortcut(KeyEvent.VK_X);
ms[6] = new MenuShortcut(KeyEvent.VK_C);
ms[7] = new MenuShortcut(KeyEvent.VK_V);
ms[8] = new MenuShortcut(KeyEvent.VK_DELETE);
ms[9] = new MenuShortcut(KeyEvent.VK_F);
ms[10] = new MenuShortcut(KeyEvent.VK_F3);
ms[11] = new MenuShortcut(KeyEvent.VK_H);
ms[12] = new MenuShortcut(KeyEvent.VK_G);
ms[13] = new MenuShortcut(KeyEvent.VK_A);
ms[14] = new MenuShortcut(KeyEvent.VK_F5);
try this:
menuItem.setAccelerator(KeyStroke.getKeyStroke(
java.awt.event.KeyEvent.VK_S,
java.awt.Event.CTRL_MASK));
where VK_S is the the key you want and CTRL_MASK is the control key.
There is another option by using
menuItem.setMnemonic('F');
this will work if you press ALT+F when running your program
for just DELETE use
jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_DELETE, 0));
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed yesterday.
Improve this question
I need to extract encryptedKey, salt, derivationMethod, derivationIterations parameters from bitcoin-like wallets (bitcoin/litecoin/dogecoin) like it is done here, but in java: https://github.com/openwall/john/blob/bleeding-jumbo/run/bitcoin2john.py
As I understand it, you need to read blocks of bytes of size 16384 until one of them contains the string mkey, but I do not yet understand how to do it all.
I did the following, but I don't know how to read the parameters further or if I even did the right thing:
FileInputStream walletFile = new FileInputStream(datFile);
byte[] curBlock = new byte[16384];
int bytesRead = walletFile.read(curBlock);
while (bytesRead > 0) {
String blockAsString = new String(curBlock, StandardCharsets.US_ASCII);
if (blockAsString.toLowerCase().contains("mkey")) {
//reading parameters
}
curBlock = new byte[16384];
bytesRead = walletFile.read(curBlock);
}
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed last year.
Improve this question
I've got a text file with this format:
image (Excluding the headers)
I need to take the account number and pin as input from the user and then match it against the values in the text. That is, check if the pin is correct for the given account number. How would I do that?
You can parse the text file and fetch data as records using CSVParser and then you can match it with the user input.
Here is the sample code:
File dataFile = new File("dataFile.txt");
//delimiter is the character by which the data is separated in the file.
//In this case it is a '\t' tab space
char dataDelimiter = '\t';
try(InputStream is = new FileInputStream(dataFile);
InputStreamReader isr = new InputStreamReader(is);
//Initializing the CSVParser instance by providing delimiter and other configurations.
CSVParser csvParser = new CSVParser(isr, CSVFormat.DEFAULT.withDelimiter('\t').withFirstRecordAsHeader())
)
{
for (CSVRecord csvRecord : csvParser)
{
long accNumber = Long.parseLong(csvRecord.get("A/C No."));
long pinNumber = Integer.parseInt(csvRecord.get("Pin"));
//-----------------
}
}
catch (IOException e)
{
e.printStackTrace();
}
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I am trying to serialize a JTree object to a file.
This is how I am doing it:
FileOutputStream f = new FileOutputStream(new File("serialisation2.txt"));
ObjectOutputStream o = new ObjectOutputStream(f);
// Write objects to file
o.writeObject(jTree1);
o.close();
f.close();
Then I am trying to read it with this:
FileInputStream fi = new FileInputStream(new File("serialisation2.txt"));
ObjectInputStream oi = new ObjectInputStream(fi);
try{
while(true){
jTree2 = new javax.swing.JTree(raíz);
System.out.println(oi.toString());
jTree2 = (JTree) oi.readObject();
}
}
But the thing is, it returns java.io.EOFException when I do oi.readObject();
Any ideas?
remove while loop, you do not really need jTree2 = new javax.swing.JTree(raíz); just jtree2 can get the deserialized value. read more about serialization here and here
FileInputStream fi = new FileInputStream(new File("serialisation2.txt"));
ObjectInputStream oi = new ObjectInputStream(fi);
jTree2 = (JTree) oi.readObject();
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have a file that stores Test questions.
"Test.ser"
I want to be able to create files with the same name but with some incrementor appended for each time someone takes the Test to store the Answers.
"Test1.ser"
"Test2.ser"
...
However, I can't think of a way to implement this. A counter could work, but the counter would reset if someone re-ran the program.
Does anyone have an idea how this is possible? Thanks a lot!
EDIT:
int count = 1;
while (searching) {
fileName = survey.name + Integer.toString(count) + ".ser";
f = new File(fileName);
if(f.exists()) {
count++;
} else {
searching = false;
}
} // Proceed to use file name
Can't get it it increment past file_name1.ser
I suggest you use String.format(String, Object...), File.exists() and something like
public static void main(String[] args) {
String fmt = "Test%02d.ser";
File f = null;
for (int i = 1; i < 100; i++) {
f = new File(String.format(fmt, i));
if (!f.exists()) {
break;
}
}
try {
System.out.println(f.getCanonicalPath());
} catch (IOException e) {
e.printStackTrace();
}
}
Edit
As pointed out in the comments, this only retries 100 times. If you want to support more then 100 retries you could write the for loop like,
for (int i = 1;; i++)
An easy way to solve this would be appending the date and the time to your filename.
For example using the format (YYYYMMDD-HHMM):
Test-20141122_2058.ser
Test-20141123_1931.ser
Test-20141123_2157.ser
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
How do I get an XML file from the assets folder using a function and save the result of the function to a String variable?
private String getXmlFile(String pathFile){
String xmlFileString = null;
AssetManager am = context.getAssets();
try {
InputStream str = am.open(pathFile);
int length = str.available();
byte[] data = new byte[length];
//str.what you want somthing to do...eg read and write str.read(data); and st.write(data);
xmlFileString = new String(data);
} catch (IOException e1) {
e1.printStackTrace();
}
return xmlFileString;
}
Maybe you can consider this AssetManager(http://developer.android.com/reference/android/content/res/AssetManager.html)
Help Full For u
AssetManager assetManager = getBaseContext().getAssets();
InputStream is = assetManager.open("order.xml");
Xml Parsing From Asset in Android