txt文本文档内容提取的Java源码
例如文本包含以下内容:=====RRCStateMachineSimulation=====DCH(Active):,363.93,S,88.62%FACH(Standb...
例如文本包含以下内容:
===== RRC State Machine Simulation =====
DCH (Active):,363.93 ,S,88.62%
FACH (Standby):,24.71 ,S,6.02%
===== Energy Efficiency Simulation =====
DCH (Active):,473.11 ,J
FACH (Standby):,7.41 ,J
现在想直接提取Energy Efficiency Simulation下的DCH (Active):值为多少(J),做一个GUI界面,效果为将一个txt文档拖放进窗体后,能直接显示相应的值,窗体界面类似下图,
求高手解答! 展开
===== RRC State Machine Simulation =====
DCH (Active):,363.93 ,S,88.62%
FACH (Standby):,24.71 ,S,6.02%
===== Energy Efficiency Simulation =====
DCH (Active):,473.11 ,J
FACH (Standby):,7.41 ,J
现在想直接提取Energy Efficiency Simulation下的DCH (Active):值为多少(J),做一个GUI界面,效果为将一个txt文档拖放进窗体后,能直接显示相应的值,窗体界面类似下图,
求高手解答! 展开
2个回答
展开全部
//看看这个能不能给你帮助
public class FormApp{
private myFrame frame;
private JTextField textField;
private JTextField textField_1;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
FormApp window = new FormApp();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the application.
*/
public FormApp() {
initialize();
}
/**
* Initialize the contents of the frame.
*/
private void initialize() {
frame = new myFrame();
frame.setTitle("鼠标拖动文件测试");
frame.setBounds(100, 100, 352, 142);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
JLabel lblNewLabel = new JLabel("源地址:");
lblNewLabel.setBounds(39, 26, 54, 15);
frame.getContentPane().add(lblNewLabel);
textField = new JTextField();
textField.setBounds(120, 23, 181, 21);
frame.getContentPane().add(textField);
textField.setColumns(10);
JLabel label = new JLabel("目标地址:");
label.setBounds(39, 62, 73, 15);
frame.getContentPane().add(label);
textField_1 = new JTextField();
textField_1.setColumns(10);
textField_1.setBounds(120, 59, 181, 21);
frame.getContentPane().add(textField_1);
}
class myFrame extends JFrame implements DropTargetListener{
public myFrame(){
new DropTarget(this, DnDConstants.ACTION_COPY_OR_MOVE, this);
}
@Override
public void dragEnter(DropTargetDragEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void dragExit(DropTargetEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void dragOver(DropTargetDragEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void drop(DropTargetDropEvent dtde) {
// TODO Auto-generated method stub
System.out.println("--------------------------------------------------------");
try {
Transferable tr = dtde.getTransferable();
if (dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
System.out.println("file cp");
List list = (List) (dtde.getTransferable()
.getTransferData(DataFlavor.javaFileListFlavor));
File f = list.get(0);
textField.setText(ConfigUtils.getProperty(f.getAbsolutePath(),"From"));
textField_1.setText(ConfigUtils.getProperty(f.getAbsolutePath(),"To"));
dtde.dropComplete(true);
}else {
dtde.rejectDrop();
}
} catch (IOException ioe) {
ioe.printStackTrace();
} catch (UnsupportedFlavorException ufe) {
ufe.printStackTrace();
}
}
@Override
public void dropActionChanged(DropTargetDragEvent arg0) {
// TODO Auto-generated method stub
}
}
}
/////////////////////////////////////////
config.ini
#Update 'To' value
#Wed Jul 16 10:18:07 CST 2014
To=C\:\\\u65B0\u5EFA\u6587\u4EF6\u5939
From=C\:\\NewErp
博思aippt
2024-07-20 广告
2024-07-20 广告
博思AIPPT是基于ai制作PPT的智能在线工具,它提供了4种AI制作PPT的方式,包括AI生成大纲、AI直接生成PPT、文本生成PPT、AI提炼word文档生成PPT,一站式集成多种AI生成PPT的方式,可满足办公用户的不同需求和使用场景...
点击进入详情页
本回答由博思aippt提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询