Send notification to all the devices connected to a Wi-Fi network

Is there any way to send a notification to the devices which are connected to a particular Wi-Fi network?

Say, I have a Wi-Fi network named “My Wi-Fi”, which is not secured, that is any one can connect. A public network.

There may be N-number of users connected to “My Wi-Fi”. These users can perform any kind of transaction, say online payment.

Now if I want to turn off or shut down “My Wi-Fi” router or access point, these transactions may fail.

So before shutting down, I want to send a text notification to all the users connected to “My Wi-Fi” network. (User does not have any kind of app in their device, to push the notification.)

Is this possible?

How to load new FXML with another controller class in the same scene

I’ve tried to load new FXML by

URL url = this.getClass().getClassLoader().getResource("pknn/fxml/CreateCharacter.fxml");if (url == null) return;
AnchorPane pane = FXMLLoader.load(url);
startPanel.getChildren().setAll(pane);

Which is worked for CreateCharacter.fxml with StartController

<AnchorPane fx:id="createCharacterPanel" onMouseEntered="#paneEventHandler" prefHeight="600.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="pknn.StartController">

But when I try to load another FXML to the same scene

URL url = this.getClass().getClassLoader().getResource("pknn/fxml/LockerRoom.fxml");
if (url == null) return;
AnchorPane pane = FXMLLoader.load(url);
createCharacterPanel.getChildren().setAll(pane);

it doesn’t work, even I change it to

startPanel.getChildren().setAll(pane);

But it still not work.
This is the fxml I want to load.

<AnchorPane fx:id="lockerRoomPane" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="pknn.LockerRoomController">

it come with so many exception like

Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
...
Caused by: javafx.fxml.LoadException: 
/Users/pknn/Study/ComPro/MonsterBattle/out/production/MonsterBattle/pknn/fxml/LockerRoom.fxml:10

at pknn.StartController.createCharacter(StartController.java:132)
Caused by: java.lang.IllegalAccessException: Class sun.reflect.misc.ReflectUtil can not access a member of class pknn.LockerRoomController with modifiers ""

How to fix it? Thanks

Is there any application capable of doing DPI (Deep Packet Inspection) to pcap files and store such information in csv files?

I am new in the deep packet inspection field. Right now i have several pcap files and i want to know if there is an application or library compatible with java or nodejs that is able to obtain the Layer 7 protocols (i.e., YouTube, Facebook, etc) from the flows of those pcap files and store such information in a csv file.

I have worked with ntopng which has nDPI but although it obtains the application protocols i am unable to store the information from each flow in a csv file. Also i have used CICFlowMeter but it only obtains the flow statistics and not the application protocols. I have been searching a lot but nothing so far.

Thanks.

Encrypting a ROT13 Programm in Java

I have a question regarding my Rot13 programm in Java. First of all, here´s my code:

import java.io.*;


public class Rot13 {

public static encrypt main(String[] args) throws IOException {
    BufferedReader myInput = new BufferedReader(new InputStreamReader(System.in));
    System.out.println("Enter a phase:");
    String input = myInput.readLine();

    for (char c : input.toCharArray()) {
        if (Character.isAlphabetic(c)) {
            char lowerChar = (char) (Character.toLowerCase(c) - 97);
            lowerChar += 13;
            lowerChar %= 26;
            lowerChar += 97;
            System.out.print(Character.isUpperCase(c) ? Character.toUpperCase(lowerChar) : lowerChar);
        } else {
            System.out.print(c);
        }
    }

    myInput.close();
}
}

Now, the programm works perfectly fine, but I was asking myself, if the Programm would look better when I´d be using the Encrypt in the programm. Other people from my University were also saying, that using encrypt in this type of programm (Rot13) would be much better then what I´m using right now.

If it´s better to use Encrypt in this programm, where should I do in oder to change my programm?

Thanks for the answers in advance^^

Decode MsgPack payload with multiple item in java using msgpack-jackson

I’m trying to decode message pack payload. They payload is written in go with the following code

var w bytes.Buffer

testBatch := []Event{
    exampleEvent,
    exampleEvent,
}

for _, e := range testBatch {
    data, err := e.MarshalMsg(nil)
    if err != nil {
        t.Fatalf("MarshalMsg failed: %v", err)
    }
    if _, err := w.Write(data); err != nil {
        t.Fatalf("Write: %v", err)
    }
}

// w.Bytes() now contain bytes that java will read.

If I understand correctly, the payload now contains 2 msgpack encoded stack which is appended together.

for decoding in java, I’m using the following libaray

https://github.com/msgpack/msgpack-java

that project contain msgpack-jackson that handle decoding message to POJO

I manage to decode the first message in java using the following code:

ObjectMapper objectMapper = new ObjectMapper(new MessagePackFactory());
Event events1 = objectMapper.readValue(in, Event.class);

// Event events2 = objectMapper.readValue(in, Event.class); // this doesn't work

events1 contain the first struct which is decoded correctly, but I did not manage to get the second struct.

un-commenting the events1 line give the following error

com.fasterxml.jackson.databind.JsonMappingException: No content to map due to end-of-input
 at [Source: java.io.ByteArrayInputStream@2374d36a; line: -1, column: 0]

My objective is to get all the struct in the payload decoded correctly in java. I could find example.

how to make expandable list using arraylist?

I need to make an expandable listview but for parent i have to pass arraylist and i am getting class cast exception in getGroupView . Please help me in writing the adapter for the following :

PhraseModel.java :

package in.abc.pdfsearchapp;

import android.os.Parcel;
import android.os.Parcelable;
import java.util.ArrayList;

public class PhraseModel implements Parcelable {

    private ArrayList<PhraseList> phraseList;

    // constructor

    public PhraseModel(ArrayList<PhraseList> phraseList) {
        this.phraseList = phraseList;
    }

    //---------------------------Getter-Setter--------------------------------------------------------------------------------
    public ArrayList<PhraseList> getPhraseList() {
        return phraseList;
    }

    public void setPhraseList(ArrayList<PhraseList> phraseList) {
        this.phraseList = phraseList;
    }

    // Parcelling

    protected PhraseModel(Parcel in) {
        phraseList=in.createTypedArrayList(PhraseList.CREATOR);
    }

    public static final Creator<PhraseModel> CREATOR = new Creator<PhraseModel>() {
        @Override
        public PhraseModel createFromParcel(Parcel in) {
            return new PhraseModel(in);
        }

        @Override
        public PhraseModel[] newArray(int size) {
            return new PhraseModel[size];
        }
    };

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeTypedList(phraseList);
    }


    //-----------------------------------   //PhraseList // ------------------------------------------------------------------------

    public static class PhraseList implements Parcelable {

        public int documentId,noOfOccurences;
        public String documentName,phrase;
        public ArrayList<OccurenceDetails> occurenceDetails;

        //constructor

        public PhraseList(int documentId, String documentName,String phrase, int noOfOccurences,  ArrayList<OccurenceDetails> occurenceDetails) {
            this.documentId = documentId;
            this.documentName = documentName;
            this.phrase = phrase;
            this.noOfOccurences = noOfOccurences;
            this.occurenceDetails = occurenceDetails;
        }
        //------------------------------Getter-Setter--------------------------------------------------------------------------------------

        public int getDocumentId() {
            return documentId;
        }

        public void setDocumentId(int documentId) {
            this.documentId = documentId;
        }

        public int getNoOfOccurences() {
            return noOfOccurences;
        }

        public void setNoOfOccurences(int noOfOccurences) {
            this.noOfOccurences = noOfOccurences;
        }

        public String getDocumentName() {
            return documentName;
        }

        public void setDocumentName(String documentName) {
            this.documentName = documentName;
        }

        public String getPhrase() {
            return phrase;
        }

        public void setPhrase(String phrase) {
            this.phrase = phrase;
        }

        public ArrayList<OccurenceDetails> getOccurenceDetails() {
            return occurenceDetails;
        }

        public void setOccurenceDetails(ArrayList<OccurenceDetails> occurenceDetails) {
            this.occurenceDetails = occurenceDetails;
        }

        //Parcelling

        protected PhraseList(Parcel in) {
            documentId = in.readInt();
            noOfOccurences = in.readInt();
            documentName = in.readString();
            phrase = in.readString();
        }

        public static final Creator<PhraseList> CREATOR = new Creator<PhraseList>() {
            @Override
            public PhraseList createFromParcel(Parcel in) {
                return new PhraseList(in);
            }

            @Override
            public PhraseList[] newArray(int size) {
                return new PhraseList[size];
            }
        };

        @Override
        public int describeContents() {
            return 0;
        }

        @Override
        public void writeToParcel(Parcel dest, int flags) {
            dest.writeInt(documentId);
            dest.writeString(documentName);
            dest.writeInt(noOfOccurences);
            dest.writeString(phrase);
        }
    }


//---------------------------------    //OccurrenceDetails // --------------------------------------------------------------------

    public static class OccurenceDetails implements Parcelable {

        int occurenceId,pageNo;
        String fullPhrase;

        //constructor

        public OccurenceDetails(int occurenceId, int pageNo, String fullPhrase) {
            this.occurenceId = occurenceId;
            this.pageNo = pageNo;
            this.fullPhrase = fullPhrase;
        }
//-------------------------------Getter-Setter----------------------------------------------------------------------------------

        public int getOccurenceId() {
            return occurenceId;
        }

        public void setOccurenceId(int occurenceId) {
            this.occurenceId = occurenceId;
        }

        public int getPageNo() {
            return pageNo;
        }

        public void setPageNo(int pageNo) {
            this.pageNo = pageNo;
        }

        public String getFullPhrase() {
            return fullPhrase;
        }

        public void setFullPhrase(String fullPhrase) {
            this.fullPhrase = fullPhrase;
        }


        //Parcelling

        protected OccurenceDetails(Parcel in) {
            occurenceId = in.readInt();
            pageNo = in.readInt();
            fullPhrase = in.readString();
        }

        public static final Creator<OccurenceDetails> CREATOR = new Creator<OccurenceDetails>() {
            @Override
            public OccurenceDetails createFromParcel(Parcel in) {
                return new OccurenceDetails(in);
            }

            @Override
            public OccurenceDetails[] newArray(int size) {
                return new OccurenceDetails[size];
            }
        };

        @Override
        public int describeContents() {
            return 0;
        }

        @Override
        public void writeToParcel(Parcel dest, int flags) {
            dest.writeInt(occurenceId);
            dest.writeInt(pageNo);
            dest.writeString(fullPhrase);
        }
    }
}

ExpandableListAdapter.java :

package in.abc.pdfsearchapp;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.BaseExpandableListAdapter;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.HashMap;

/**
 * Created by Android on 22-Nov-17.
 */

public class ExpandableListAdapter extends BaseExpandableListAdapter {

    Context context;
    public ArrayList<PhraseModel.PhraseList> mPhraseList;
    private HashMap<Integer,ArrayList<PhraseModel.OccurenceDetails>> occurenceList;

    public ExpandableListAdapter(Context context, ArrayList<PhraseModel.PhraseList> mPhraseList, HashMap<Integer, ArrayList<PhraseModel.OccurenceDetails>> occurenceList) {
        this.context = context;
        this.mPhraseList = mPhraseList;
        this.occurenceList = occurenceList;
    }

    public Object getChild(int groupPosition, int childPosition){
        return this.occurenceList.get(this.mPhraseList.get(groupPosition)).get(childPosition);
    }


    public long getChildId(int groupPosition, int childPosition) {
        return childPosition;
    }


    public View getChildView(int groupPosition, final int childPosition,
                        boolean isLastChild, View convertView, ViewGroup parent) {

        final ArrayList<PhraseModel.OccurenceDetails> childList = (ArrayList<PhraseModel.OccurenceDetails>) getChild(groupPosition, childPosition);
        if(convertView==null){
            LayoutInflater infalInflater = (LayoutInflater) this.context
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = infalInflater.inflate(R.layout.list_item, null);
        }

        TextView occurenceId,fullPhrase,pageNo;
        occurenceId=(TextView)convertView.findViewById(R.id.occurenceId);
        fullPhrase=(TextView)convertView.findViewById(R.id.fullPhrase);
        pageNo=(TextView)convertView.findViewById(R.id.pageNo);

        occurenceId.setText(childList.get(groupPosition).getOccurenceId());
        fullPhrase.setText(childList.get(groupPosition).getFullPhrase());
        pageNo.setText(childList.get(groupPosition).getPageNo());

        return convertView;
    }

    public int getChildrenCount(int groupPosition) {
        return this.occurenceList.get(this.mPhraseList.get(groupPosition))
                .size();
    }

    public Object getGroup(int groupPosition) {
        return this.mPhraseList.get(groupPosition);
    }

    public int getGroupCount() {
        return this.mPhraseList.size();
    }

    public long getGroupId(int groupPosition) {
        return groupPosition;
    }

    public View getGroupView(int groupPosition, boolean isExpanded,
                             View convertView, ViewGroup parent) {
        ArrayList<PhraseModel.PhraseList> parentList = (ArrayList<PhraseModel.PhraseList>) getGroup(groupPosition);
        if (convertView == null) {
            LayoutInflater infalInflater = (LayoutInflater) this.context
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = infalInflater.inflate(R.layout.list_group, null);
        }

        TextView docName,totalOccurences;
        docName=(TextView)convertView.findViewById(R.id.docName);
        totalOccurences=(TextView)convertView.findViewById(R.id.totalOccurences);
        docName.setText(parentList.get(groupPosition).getDocumentName());
        totalOccurences.setText(parentList.get(groupPosition).getNoOfOccurences());
        return convertView;
    }

    public boolean hasStableIds() {
        return false;
    }

    public boolean isChildSelectable(int groupPosition, int childPosition) {
        return true;
    }
}

LandingActivity.java :

package in.abc.pdfsearchapp;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.ExpandableListView;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;

public class LandingActivity extends AppCompatActivity {

    ExpandableListAdapter listAdapter;
    ExpandableListView expListView;
    ArrayList<PhraseModel.PhraseList> phraseLists;
    HashMap<Integer, ArrayList<PhraseModel.OccurenceDetails>> occurenceList;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_landing);

        expListView = (ExpandableListView) findViewById(R.id.phraseList);

        // preparing list data
        phraseLists=new ArrayList<PhraseModel.PhraseList>();
        occurenceList=new HashMap<Integer,ArrayList<PhraseModel.OccurenceDetails>>();
        phraseLists.addAll(getmphraseset());

        for (PhraseModel.PhraseList pl: phraseLists){
            ArrayList<PhraseModel.OccurenceDetails>occurenceDetailses=pl.getOccurenceDetails();
            occurenceList.put(pl.getDocumentId(),occurenceDetailses);
        }

        System.out.println(occurenceList.size());

        listAdapter = new ExpandableListAdapter(this, phraseLists,occurenceList);

        // setting list adapter
        expListView.setAdapter(listAdapter);
    }

    private ArrayList<PhraseModel.PhraseList> getmphraseset() {
        try{
            ArrayList<PhraseModel.PhraseList>phrase_Lists = new ArrayList<PhraseModel.PhraseList>();
            ArrayList<PhraseModel.OccurenceDetails>occurenceDetailsArrayList=new ArrayList<PhraseModel.OccurenceDetails>();
            JSONObject jsonObject = new JSONObject(readJSONFromAsset());

            JSONArray phraseArray = jsonObject.getJSONArray("phraseList");
            Log.d("getmphraseset", "phrase count: "+phraseArray.length());
            for (int i = 0; i < phraseArray.length(); i++)
            {
                JSONObject job = phraseArray.getJSONObject(i);

                int documentId =job.getInt("documentId");
                int noOfOccurences=job.getInt("noOfOccurences");

                String documentName=job.getString("documentName");
                String phrase=job.getString("phrase");

                //This i for Occurences array
                ArrayList<PhraseModel.OccurenceDetails> occurencesList = new ArrayList<>();
                JSONArray occurencesArray = job.getJSONArray("occurenceDetails");
                for (int j = 0; j < occurencesArray.length(); j++) {
                    JSONObject jobIn = occurencesArray.getJSONObject(j);

                    int occurenceId=jobIn.getInt("occurenceId");
                    int pageNo=jobIn.getInt("pageNo");
                    String fullPhrase=jobIn.getString("fullPhrase");

                    occurencesList.add(new PhraseModel.OccurenceDetails(occurenceId, pageNo, fullPhrase));

                }

                //here your Phrase[] value store in pdfArrayList
                phrase_Lists.add(new PhraseModel.PhraseList(documentId,documentName,phrase,noOfOccurences,occurencesList));

                Log.i("phraseList size = ", ""+phraseArray.length());
            }

            if (phrase_Lists != null)
            {
                Log.i("phraseList size = ", ""+phraseArray.length());
            }
            return phrase_Lists;
        }catch (JSONException e){
            e.printStackTrace();
            return null;
        }
    }

    @Override
    protected void onResume() {
        super.onResume();
    }

    public String readJSONFromAsset() {
        String json = null;
        try {
            InputStream is = getAssets().open("hipaJson.json");
            int size = is.available();
            byte[] buffer = new byte[size];
            is.read(buffer);
            is.close();
            json = new String(buffer, "UTF-8");
        } catch (IOException ex) {
            ex.printStackTrace();
            return null;
        }
        return json;
    }
}

Please explain and help, what i am doing wrong?? The app has splashscreen > landingActivity containing expandable list which i am not able to show as app crashes giving class cat exception in getGroupView method.

Java SimpleDateFormat does not parse correctly (I am using the correct uppercase/lowercase letters..)

I know this has been asked several times and I am risking a downvote/duplicate close, but most of the questions posted here were resolved by chaing YYYY into yyyy..so, searching does not really help :/

These are the given timestamps inside the block

date new Block: 2017-11-02T06:17:05.079481
date old Block: 2017-11-02T06:17:04.608960

My conversion code:

 public static Date getDate(JSONObject block){
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-DD'T'HH:mm:ss.SSSSSS");
    try {
       return sdf.parse(block.get("timestamp").toString());
    } catch (ParseException e) {
        e.printStackTrace();
        return new Date(0);
    }
}

And this is the result of parse

date new block: Mon Jan 02 06:18:24 KST 2017 
date old block: Mon Jan 02 06:27:12 KST 2017

How is that possible? First of all, 11 becomes January, even though the JavaDoc says Month: If the number of pattern letters is 3 or more, the month is interpreted as text; otherwise, it is interpreted as a number. and the other timestamps dont add up either.

How to make a fxml layout resizible

I have a one page java fx application and i want to make the layout resizible but i don’ know how.
This is the code :

 <?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.*?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.*?>
<GridPane fx:id="home" alignment="center" gridLinesVisible="true" hgap="10" vgap="10"
          xmlns="http://javafx.com/javafx/8.0.112" xmlns:fx="http://javafx.com/fxml/1"
          fx:controller="sample.Controller">

    <AnchorPane prefHeight="748.0" prefWidth="1360.0" styleClass="section2">
        <AnchorPane layoutX="0.0" layoutY="40.0" prefHeight="768.0" prefWidth="1359.0">
            <children>
                <Button layoutX="37.0" layoutY="281.0" mnemonicParsing="false" onAction="#ReadMainData"
                        prefHeight="25.0" prefWidth="171.0" styleClass="sectionRead" text="Read Main Data"/>
                <Button layoutX="37.0" layoutY="316.0" mnemonicParsing="false" onAction="#ReadStructural"
                        prefHeight="25.0" prefWidth="171.0" styleClass="sectionRead" text="Read Mass Properties"/>
                <Button layoutX="37.0" layoutY="384.0" mnemonicParsing="false" onAction="#ReadNumParts"
                        prefHeight="25.0" prefWidth="171.0" styleClass="sectionRead" text="Read Part List"/>
                <Button layoutX="37.0" layoutY="572.0" mnemonicParsing="false" onAction="#WriteIdentification"
                        prefHeight="25.0" prefWidth="171.0" styleClass="sectionWrite" text="Write Main Data"/>
                <Button layoutX="37.0" layoutY="609.0" mnemonicParsing="false" onAction="#WriteMassProperty"
                        prefHeight="25.0" prefWidth="171.0" styleClass="sectionWrite" text="Write Mass Properties"/>
                <Button layoutX="37.0" layoutY="678.0" mnemonicParsing="false" onAction="#WriteNumParts"
                        prefHeight="25.0" prefWidth="171.0" styleClass="sectionWrite" text="Write Part List"/>
                <Label alignment="CENTER" layoutX="52.0" layoutY="10.0" prefHeight="33.0" prefWidth="106.0"
                       text="choose the port"/>
                <ChoiceBox fx:id="choice" accessibleText="Choice" layoutX="60.0" layoutY="64.0"
                           onMousePressed="#fillComboBox" prefHeight="25.0" prefWidth="89.0">

                    <items>

                    </items>

                </ChoiceBox>

                <AnchorPane fx:id="paneSample" layoutX="260.0" layoutY="10.0" prefHeight="700.0" prefWidth="1096.0"
                            styleClass="section1"/>


                <Label fx:id="sampleVisualizzaId" alignment="CENTER" layoutX="42.0" layoutY="114.0" prefHeight="33.0"
                       prefWidth="125.0" text="ID"/>
                <Button fx:id="readId" layoutX="60.0" layoutY="179.0" mnemonicParsing="false" onAction="#getUid"
                        prefHeight="33.0" prefWidth="89.0" text="Get ID"/>
                <ImageView fitHeight="62.0" fitWidth="60.0" layoutX="84.0" layoutY="467.0" pickOnBounds="true"
                           preserveRatio="true">
                    <image>
                        <Image url="/sample/g logo.png"/>
                    </image>
                </ImageView>
                <Button layoutX="37.0" layoutY="348.0" mnemonicParsing="false" onAction="#ReadGeometricProperties"
                        prefHeight="25.0" prefWidth="171.0" styleClass="sectionRead" text="Read Geometric Properties"/>


                <Button layoutX="37.0" layoutY="644.0" mnemonicParsing="false" onAction="#WriteBasic" prefHeight="25.0"
                        prefWidth="171.0" styleClass="sectionWrite" text="Write Geometric Properties"/>


            </children>
        </AnchorPane>


    </AnchorPane>

</GridPane>

How you see the layout is maded by two anchor pane in which. The layout is a master detail layout.When the user push on of the button the program update the second anchor pane with the specific layout for the app.
The application work fine but i want to make it resizible thanks for help!!!